The Panel Class The PictureBox Class

198 Two properties determine the date range that users can select: MinDate and MaxDate. The MinDate property is a DateTime value representing the minimum date permitted; its default is January 1, 1753. The MaxDate property determines the maximum date allowed. By default, the value of MaxDate is December 31, 9998. If you want your MonthCalendar to display a certain range of dates, you need to change these two properties. For instance, the following code allows the user to select a date between January 1, 1980 and December 14, 2010: MonthCalendar1.MinDate = New DateTime1980, 1, 1 MonthCalendar1.MaxDate = New DateTime2010, 12, 14 The MonthCalendar class has a TodayDate property that represents todays date. The user selecting a new date does not automatically change the value of TodayDate. If you want the date selected by the user to be reflected as todays date, you can use the Date_Changed event handler to change its value explicitly, as shown in the following code: Private Sub MonthCalendar1_DateChanged _ ByVal sender As System.Object, _ ByVal e As DateRangeEventArgs _ Handles MonthCalendar1.DateChanged MonthCalendar1.TodayDate = e.Start End Sub A DateRangeEventArgs object is passed as an argument to the DateChanged event handler. Its members include a Start property, which represents the beginning of the range of selected dates, and an End property, which represents the end of the range of selected dates. The previous code simply assigns the value of the Start property to TodayDate. Later, if you need to know the value of the user- selected date, you can query the TodayDate property. Note that the MonthCalendar control has a fixed size. It will ignore any attempt to change its Size property. If you need more flexibility in terms of the space it occupies, use a DateTimePicker control.

5.1.13 The Panel Class

A panel is a container that can hold other controls. Panels are typically used to group related controls in a form. Like the PictureBox class, the Panel class has a BorderStyle property that defines the panels border and can take as its value any member of the BorderStyle enumeration: None the default value, FixedSingle , and Fixed3D . You can add controls to a Panel object using the Add method or the AddRange method of the Control.ControlCollection class. The following code adds a button and a text box to a Panel control called panel1: 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