|
-
Jun 6th, 2007, 07:04 PM
#1
Thread Starter
Fanatic Member
help with setting the width
hi guys! i have a simple problem that i can't figure out..how can i set the width value of my form i've tried the code below but i think that is not the proper way. by the way, i only want to set the width value. Thanks in advance!
Code:
this.Size.Width = 5;
-
Jun 6th, 2007, 07:56 PM
#2
Re: help with setting the width
You set the Width property of the form itself.
The reason that the code you posted won't work is that Size is a structure, not a class, so the Size property of your form is a value type. That means that when you get the Size property of the form it returns a copy containing the same value as the Size object contained in your form. If you try to set the Width as you're doing above then you're setting the Width property of the copy, which won't affect the original and therefore won't affect the form. You cannot set a property of a property directly if the parent property is a value type. If you wanted to use the Size property you'd have to do this:
C# Code:
Size sz = this.Size;
sz.Width = 5;
this.Size = sz;
The form class provides its own Width property so you don't have to do that.
-
Jun 6th, 2007, 09:48 PM
#3
Thread Starter
Fanatic Member
Re: help with setting the width
Ok thanks for that JM. The code below also works to me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|