The RadioButton Class Common Controls and Components

199 Dim panel1 As Panel = New Panel Dim textBox1 As TextBox = New TextBox Dim WithEvents button1 As Button button1 = New Button button1 button1.Location = New System.Drawing.Point104, 72 button1.Name = button1 button1.Size = New System.Drawing.Size64, 48 button1.TabIndex = 0 button1.Text = Button1 textBox1 textBox1.Location = New System.Drawing.Point128, 48 textBox1.Name = textBox1 textBox1.TabIndex = 1 panel1.Controls.AddRangeNew Control {textBox1, button1} panel1.Location = New System.Drawing.Point24, 24 panel1.Name = Panel1 panel1.Size = New System.Drawing.Size336, 216 Me.Controls.Addpanel1

5.1.14 The PictureBox Class

The PictureBox class represents a control to display an image. Loading an image into this control is achieved by assigning a System.Drawing.Bitmap object to its Image property, as the following code does: Dim pictureBox1 As PictureBox = New PictureBox pictureBox1.Image = New System.Drawing.Bitmapc:\tv.bmp pictureBox1.Location = New System.Drawing.Point72, 64 pictureBox1.Size = New System.Drawing.Size144, 128 Me.Controls.AddpictureBox1 In addition, the PictureBox class has the BorderStyle and SizeMode properties. The BorderStyle property determines the PictureBox objects border and can take as its value any member of the BorderStyle enumeration: None the default value, FixedSingle , and Fixed3D . The SizeMode property determines how the image assigned to the Image property is displayed. The SizeMode property can take any of the members of the PictureBoxSizeMode enumeration: AutoSize , CenterImage , Normal the default value, and StretchImage .

5.1.15 The RadioButton Class

The RadioButton class represents a radio button. When you add more than one radio button to a form, those radio buttons automatically become one group, and you can select only one button at a time. If you want to have multiple groups of radio buttons on a form, you need to use a GroupBox or Panel control to add radio buttons in the same group to a single GroupBox or Panel. The following code shows how you can add two radio buttons to a GroupBox and then add the GroupBox to a form. Notice that you dont need to add each individual radio button to a form: Declare and instantiate a GroupBox and two radio buttons. Dim groupBox1 As GroupBox = New GroupBox Dim radioButton1 As RadioButton = new RadioButton Dim radioButton2 As RadioButton = new RadioButton 200 Set the Size and Location of each control. groupBox1.Size = New System.Drawing.Size248, 88 groupBox1.Location = New System.Drawing.Point112, 168 radioButton1.Location = New System.Drawing.Point16, 10 radioButton1.Size = New System.Drawing.Size104, 20 radioButton2.Location = New System.Drawing.Point16, 50 radioButton2.Size = New System.Drawing.Size104, 20 Add radioButton1 and radioButton2 to the GroupBox. groupBox1.Controls.AddRangeNew Control {radioButton1, radioButton2} Add the GroupBox to the form. Me.Controls.AddgroupBox1 Like a checkbox, the appearance of a radio button is determined by its Appearance property, which can take one of two members of the Appearance enumeration: Normal the default and Button . You dont normally use Appearance.Button because it will make your radio button look like a button. The CheckAlign property determines the text alignment of the radio button. Its value is one of the members of the ContentAlignment enumeration: BottomCenter , BottomLeft , BottomRight , MiddleCenter , MiddleLeft the default, MiddleRight , TopCenter , TopLeft , and TopRight . The Checked property takes a Boolean. Setting this property to True selects the radio button and deselects others in the group; setting it to False unselects it.

5.1.16 The TextBox Class