Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Visual C#  Unable to alter size or position of form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin R - 31 Dec 2004 14:13 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.