location / size

ADO DOT NET

Centurion
Joined
Dec 20, 2006
Messages
160
Visual Basic:
OKButton.Location.X = 81
OKButton.Location.Y = 165
OKButton.Size.Height = 22
OKButton.Size.Width = 65
Why I get error while using those command? how can I assign the location and size of a control in runtime then? :confused:
 
You'll have to set the Location and Size properties themselves. Try this:
Visual Basic:
OKButton.Location = New Point(81, 165)
OKButton.Size = New Size(22, 65)

-ner
 
When updating the bounds of UI objects, it is best to do them all at once. It will reduce flicker and if a large number of updates are made, they will go much more quickly. Ideally, the code should read something like:
Code:
OKButton.Bounds = [COLOR="Blue"]New[/COLOR] Rectangle(81, 165, 22, 65)
If you just wanted to change the size, or just wanted to change the location, code like that posted by Nerseus would be best. If you just want to change one aspect of the bounds, just the X or Y or width or height, then you would use the Left, Top, Width, or Height properties (respectively).

The reason that you can't use the OKButton.Location.X property is rather technical, but it should suffice to say that you although you can't modify part of the Location (or size) properties, you can assign a new Point or Size object to those properties.
 
Back
Top