|
|
Title | Set a form's client area size in Visual Basic .NET |
Description | This example shows how to set a form's client area size in Visual Basic .NET. |
Keywords | size, client area, ClientSize, form, VB.NET |
Categories | Controls, VB.NET, Graphics |
|
|
When you click the radio buttons, the program sets the form's ClientSize to a new Size value. It saves the new client width and height in variables and invalidates the form. The Paint event handler then draws an ellipse that touches the edges of the client area.
|
|
Dim m_Wid As Integer
Dim m_Hgt As Integer
Private Sub rad300x200_CheckedChanged(...) Handles _
rad300x200.CheckedChanged
Me.ClientSize = New Size(300, 200)
m_Wid = 300
m_Hgt = 200
Me.Invalidate()
End Sub
Private Sub rad400x400_CheckedChanged(...) Handles _
rad400x400.CheckedChanged
Me.ClientSize = New Size(400, 400)
m_Wid = 400
m_Hgt = 400
Me.Invalidate()
End Sub
Private Sub Form1_Paint(...) Handles MyBase.Paint
e.Graphics.DrawEllipse(Pens.Red, 0, 0, m_Wid - 1, m_Hgt _
- 1)
End Sub
|
|
|
|
|
|