Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

  • *Experts*
Posted

You'll have to set the Location and Size properties themselves. Try this:

OKButton.Location = New Point(81, 165)
OKButton.Size = New Size(22, 65)

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • Leaders
Posted

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:

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.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...