Additional Controls
16_additional_controls.ppt
Single Document Interface (SDI)
Multiple Document Interface (MDI)
ToolStrip Control
Calendar Controls
CIS162AD 2
Each form is in a separate window that acts independently from the other forms in the application.
This what we have created so far.
Even when we display another form (ShowDialog), the 2 nd form is displayed in its own window, for example the About form. It is independent of the startup or main form.
CIS162AD 3
Multiple forms are displayed within the same window.
Parent form (main window) "contains" other forms.
Many Child forms (document windows) can be
"contained within" Parent window.
Parent and Child may share menus, toolbars, etc.
Should add a Window menu option that allows users:
– To switch between opened documents.
– Display documents as Tile Vertically, Tile Horizontally or
Cascade.
CIS162AD 4
CIS162AD
5
At design time designate a form as Parent.
– IsMdiContainer property = True
At run time designate Child forms.
Create an instance of the child form, but before displaying the child form set the child's MdiParent property to the current form using the this reference.
{ private void tbbChild1_Click(object sender, EventArgs e)
ChildForm1 frmChild1 = new ChildForm1( ); frmChild1.MdiParent = this ; frmChild1.Show();
}
CIS162AD 6
Allows the user to arrange multiple Child forms.
Allows the user to switch between documents.
To list opened Child documents
– Create a Windows menu item
(mnuWindows)
– On the menuStrip, set
MdiWindowListItem property to the Windows menu item name
(mnuWindows).
– This will list the child documents automatically.
CIS162AD 7
Use the LayoutMdi method to set the type of layout: this .
LayoutMdi ( MdiLayout .TileHorizontal); this.
LayoutMdi ( MdiLayout .TileVertical); this.
LayoutMdi ( MdiLayout .Cascade);
{ private void mnuWindowTileHortzonal_Click(object sender, EventArgs e) this.LayoutMdi(MdiLayout.TileHorizontal);
}
CIS162AD 8
CIS162AD
9
Place the ToolStrip control on the form.
Click on the Add ToolStripButton to get a dropdown list of options.
Select the first one, Button to add a button to the toolStrip .
Click on a button to select it, and then set the properties for it, including the Name (tbbChild1), Image, and Text. Text becomes the tool tip.
CIS162AD 10
Each button on the toolStrip has its own ButtonClick event.
Double click on the button to create the default method and enter the required code.
private void tbbChild1_Click(object sender, EventArgs e)
{
ChildForm1 frmChild1 = new ChildForm1( ); frmChild1.MdiParent = this; frmChild1.Show();
}
CIS162AD 11
CIS162AD
DateTimePicker MonthCalendar
12
Provides the ability to display calendars on a form.
DateTimePicker
– Displays only day and date unless user drops down the calendar.
– Value property contains date.
MonthCalendar
– Displays entire month as a calendar.
– Stores a date range, so values are stored in
SelectionRange.Start and SelectionRange.End
Event triggered when value or date is changed.
CIS162AD 13
Single Document Interface (SDI)
Multiple Document Interface (MDI)
Toolbar Control
Calendar Controls
CIS162AD 14