Hi
I have this in a method which is called when my form is created
public CreateDevice()
{
// Set the initial size of our form
this.Top = 0;
this.Left = 0;
this.Size = new System.Drawing.Size(500,800);
//this.ClientSize = new System.Drawing.Size(400,300);
// And it's caption
this.Text = "Rhubarb: CreateDevice";
// Load our icon from the resources of the .exe
this.Icon = new Icon(this.GetType(), "directx.ico");
}
the method is being called OK, because the forms text is being set to
what ever I want it to be. But attempts to set the Top, Left or Size
members are having no effect at all, the same with attempts to set the
ClientSize member.
I can resize the form by dragging, when it is running.
I am completely new to C# so it may be something really dumb.
Any ideas
Kevin R.
Kevin R - 31 Dec 2004 15:04 GMT
>Hi
>I have this in a method which is called when my form is created
[quoted text clipped - 22 lines]
>
>Kevin R.
The form is actually called CreateDevice. Hence the method above is
the constructor.
I can set the Left and Top properties dynamically provided that at
design time I set the form's StartPosition property to Manual.
If I move my attempts to set the size to the InitializeComponent()
method then all is OK.
Strange that I can set the Text, Left and Top properties within the
constructor, but not the Size property. I am probably missing
something.
Problem is sorted for know, but I would be interested to know what the
problem with doing this in the constructor was.
Kevin R.
Ken Allen - 31 Dec 2004 16:22 GMT
In general, these types of changes should be made in the Load() handler,
and not in the constructor, as the underlying Windows objects do not yet
exist.
-ken
>>Hi
>>I have this in a method which is called when my form is created
[quoted text clipped - 40 lines]
>
> Kevin R.