MCC - CIS162AD
CS14 Additional Controls - 20 points![]()
Create a Multiple Document Interface (MDI) project that includes a Toolbar and Calendar controls.
Sample Form:
![]()
Outline to complete project:
- Create a new project (CS14).
- Create 3 forms (frmMain, frmChild1, frmChild2)
Click on Project on the menu and select Add Windows Form...
- On frmMain set IsMdiContainer property to True.
- Add a MenuStrip to MainForm that includes the options Exit (mnuExit) and Window (mnuWindow).
- Click on menuStrip1 once to select, and set the MdiWindowListItem property to mnuWindow.
- Exit should close the application (this.Close).
- Under the Window menu option add the options to Tile Horizontally and Cascade Windows.
- Double click on the Tile Horizonatally and Casade Windows menu options to create the click event methods.
- Use the LayoutMdi method in each method to set the type of layout:
this.LayoutMdi(MdiLayout.TileHorizontal);
this.LayoutMdi(MdiLayout.Cascade);
Example:private void mnuWindowCascade_Click(object sender, EventArgs e) { this.LayoutMdi(MdiLayout.Cascade); }- Add a ToolStrip control (toolStrip1) to MainForm.
- Add 2 Buttons (tbbChild1, tbbchild2) using the Add ToolStripButton dropdown list.
- Assign an image to each button.
Use the Import button to select the image for each button.
Look in the Windows or WinNT directory for images. For this assignment you may select any appropriate image stored on the computer or download these.
Internet Explorer may not display the images file (.ico) correctly, but you should still be able to download the images as described in the next line.
Icon Files: Right-click on image and select Save Image As or Save Picture As.
Tablet:Pen:
![]()
- Double-click on the buttons to create the click methods.
- Add the code to create an instance of a child form, assign it to the parent, and then show it.
private void tbbChild1_Click(object sender, EventArgs e) { frmChild1 frmChild1Obj = new frmChild1(); frmChild1Obj.MdiParent = this; //this points to the parent form frmChild1Obj.Show(); }frmMain In Design Mode:
Submit the following files:
![]()
- On frmChild1 add a textbox (txtDate) and a DateTimePicker (dateTimePicker1). Double-click on dateTimePicker1 to create the ValueChanged method, and then add code to display the selected date in txtDate when the value is changed. For DateTimePicker the date is stored in the Value property.
private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { txtDate.Text = dateTimePicker1.Value.ToString(); }- On frmChild2 add a textbox (txtDate) and a MonthCalendar (monthCalendar1). Double-click on monthCalendar1 to create the DateChanged method, and then add code to display the selected date range in txtDate when the date is changed. For MonthCalendar the date range is stored in the SelectionRange property as Start and End.
private void monthCalendar2_DateChanged(object sender, DateRangeEventArgs e) { txtDate.Text = monthCalendar1.SelectionRange.Start + " - " + monthCalendar1.SelectionRange.End; }
MainForm.cs, MainForm.Designer.cs, Child1Form.cs, Child1Form.Designer.cs, Child2Form.cs, and Child2Form.Designer.cs
Revised: 05/03/2011 - www.mesacc.edu/~marquez/cis162ad/cs14_additional_controls.html