|
Try out this code as an example -
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Button button1;<br />
private bool drawline = false;<br />
private int radius = 25;<br />
private int green = 10;<br />
private int red = 10;<br />
private int blue = 10;<br />
}<br />
<br />
<br />
private void Button_1OK__Click(object sender, System.EventArgs e)<br />
{<br />
drawline = !drawline;<br />
Random r = new Random(100);<br />
Int32 x = Int32.Parse(r.Next().ToString().Substring(1,2));<br />
Int32 y = Int32.Parse(r.Next().ToString().Substring(1,3));<br />
<br />
if (green < 230)<br />
green += 10;<br />
<br />
if (blue < 230)<br />
blue += 10;<br />
<br />
if (red < 230)<br />
red += 10;<br />
<br />
if (drawline)<br />
{<br />
System.Drawing.Graphics g = this.CreateGraphics();<br />
Point P = new Point(x,100);<br />
Point p1 = new Point (100,y);<br />
Color j = Color.FromArgb(red,green,blue);<br />
Pen Pe = new Pen(j);<br />
<br />
g.DrawEllipse(Pe,x,x ,radius, radius);<br />
radius += 20;<br />
}<br />
else<br />
{<br />
System.Drawing.Graphics g = this.CreateGraphics();<br />
Point P = new Point(x,100);<br />
Point p1 = new Point (100,y);<br />
Color j = Color.FromArgb(red,green,blue);<br />
Pen Pe = new Pen(j);<br />
<br />
g.DrawEllipse(Pe,y,y ,radius, radius);<br />
radius += 20;<br />
this.Refresh();<br />
}<br />
}
Regards
Mahesh
|
|
|
|
|
Is there a property build for a DataGrid in a C# Windows Application?
I have used this feature when building web applications, but it does not appear to be present as I am building a Windows application and want to do a basic layout for my datagrid without manually constructing the data columns and features.
Thanks.
SD
|
|
|
|
|
The WinForms DataGrid is really inflexible if you're used to using the asp:DataGrid control. I'm afraid you're going to have to manually construct the stuff you want.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
Thanks...I was afraid of that.
William
|
|
|
|
|
Hi all
I want to make a user defined control which combine a textbox and DateTimepicker. I write the following code for the Resize event
Size wholesize = this.Size;
int x = wholesize.Width;
wholesize.Height = 21;
Point location = new Point(x - 20, 21);
this.calendar.Location = location;
Size newsize = new Size(wholesize.Width-20, 21);
this.textbox.Size = newsize;
But this code doesn't work, could anybody tell me how to redraw the user control, when I resize it???
Thanks in advance!
Asura
|
|
|
|
|
Hmmm... you give us some code which you say doesn't do what you want it to do. But you also don't describe what you exactly want to do... Are we going to guess what you want?
You'll have to explain a bit more if we should help you. But here is a more general tip:
Instead of calculating the new sizes yourself you should use the docking and/or anchoring mechansims of .Net controls. If you want a DateTimePicker at the top and a TextBox filling out the rest of the control you would assign DockStyle.Top to the Dock property of the DateTimePicker and DockStyle.Fill to the TextBox.
Note that when using docking the order of the controls in the form are relevant (and can be changed via the designer).
|
|
|
|
|
Guys,
I need your help..
I need to modify the difficulty level of the lunar lander game..
is it possible to change the dy to .5?? is there any better suggestions in here??
private void timer1_Tick(object sender, System.EventArgs e) {
//code that should happen on every timer tick (10 times/sec)
//account for gravity
dy+= .5;
//increment score for being alive
score += 100;
//show ordinary (no flames) lander
picLander.Image = myPics.Images[0];
moveShip();
checkLanding();
showStats();
} // end timer tick
thanks...
|
|
|
|
|
What implementation of this game are you referring to?
But yes, in general it helps just raising the gravity to make it harder.
|
|
|
|
|
hello,
i have a panel which i draw stuff on using the DrawPolygon method of the Graphics object. i have a collecition of Building objects. each building object has an array of points associated with it. On the paint event of the panel object, i iterate through all the buildings and draw them one by one.
the question is, 1) how do i know if the mouse is within the bounderies of one of the building?
2) i use the transformation matrix to zoom in to the drawing. will the answer to number 1 work when i zoom in?
thanks,
michael
|
|
|
|
|
Hi!
When I start remote host as the service, it stops giving me the messsage that the service has got no work.Please help if anybody has idea about this.
Akshay
|
|
|
|
|
can anyone help me.I get problems with DataGrids not firing their PageIndexChanged event.Here is code which i m trying:
private void DataGrid1_OnPageIndexChanged(object sender,System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataSource = oDv;
DataGrid1.DataBind();
}
|
|
|
|
|
What's the difference between a struct and a class? why should i use a struct?
|
|
|
|
|
|
struct is value type and class is reference type ... this is the main differece. Martin
|
|
|
|
|
WTF?
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Sorry Tim, but he is right!
|
|
|
|
|
The only difference between a struct and a class is that the members of a class default to "private" while the members of a struct default to "public".
Often, for simple data containers, people still use a struct.
i.e.
struct BOB { int a; int b; };
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
ROFL... How the **** did I end up here.
Sorry guys. LOL.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
Hi,
Methods in an interface must be public?
If i have a public method in an interface, can i make this method "internal" (or any other access parameter) in a class derived from the interface?
ie:
public interface myinter
{
public void MyMethod(){}
}
public class myclass : myinter
{
internal void MyMethod(){//my code}
}
|
|
|
|
|
Heinz Suez wrote:
Methods in an interface must be public?
Yes, that is the point. It is defining the external interface* to something. In other words, it is defining the interface* (or part of the interface*) to your class that other classes use.
Heinz Suez wrote:
If i have a public method in an interface , can i make this method "internal" (or any other access parameter) in a class derived from the interface ?
No. You cannot. This is because the class would then no longer support the interface it advertises as supporting.
Do not confuse "interface" with the C# keyword "interface ". An interface is another way of saying how an external entity sees the class. You provide an interface with any public methods. An interface is a way of defining a common set of public methods or properties that a number of classes support.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
First of all your code won't compile
And yes all members of an interface must be public visible to everyone using this interface. But you can restrict them ONLY to explicit interface users:
public interface ITest
{
void TestA();
}
public class Class1 : ITest
{
void ITest.TestA() {}
}
static void Main()
{
Class1 c = new Class1();
c.TestA();
ITest t = c;
t.TestA();
}
|
|
|
|
|
I can't seem to figure out how to get the selected date from a MonthCalendar. The DateTime picker has a value property, but I can't find the same for the MonthCalendar. How do I get the selected date from the MonthCalendar?
Thanks
|
|
|
|
|
hope this helps,
add a dateselected handler and use the eventargst oget teh datetime of the selected data, then just use the datatime properties.
<br />
<br />
private void monthCalendar1_DateSelected(object sender, System.Windows.Forms.DateRangeEventArgs e)<br />
{<br />
this.textBox1.Text = "Date Selected: Start = " +<br />
e.Start.ToShortDateString() + " : End = " + e.End.ToShortDateString();<br />
}<br />
<br />
regs,
g00fy
|
|
|
|