Other Handy Programming Tips


Here are some other handy programming tips for using Windows Forms:

  • Switch the focus to a control - Use the .Focus() method. To set the focus to TextBox1, for example, use the following code:

     TextBox1.Focus()

  • Quickly determine the container control or parent form - With the use of group boxes and panels, controls are often contained many times. You can now use the FindForm method to immediately get a reference to the form. Use the GetContainerControl method to access the immediate parent of a control.

  • Traversing the tab order - Use the GetNextControl method of any control to get a reference to the next control on the form in the tab order.

  • Convert client coordinates to screen coordinates (and back) - Want to know where a control is in screen coordinates? Use the PointToScreen method. Convert back using the PointToClient method.

  • Change the z-order of controls at runtime - Controls now have both BringToFront and SendToBack methods.

  • Locate the mouse pointer - The control class now exposes a MousePosition property that returns the location of the mouse in screen coordinates.

  • Managing child control - Container controls, such as a group box or panel, can use the HasChildren property and Controls collection to determine the existence of, and direct references to, child controls, respectively.

  • Maximize, minimize, restore a form - Use the form’s WindowState property.




Professional VB 2005 with. NET 3. 0
Professional VB 2005 with .NET 3.0 (Programmer to Programmer)
ISBN: 0470124709
EAN: 2147483647
Year: 2004
Pages: 267

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net