Full WinForms Project
Build a complete Windows Forms application using all 29 controls from the Toolbox. Follow this step-by-step guide.
MainForm.Designer.cs file.
The designer file is auto-generated and will be updated automatically when you drag controls.
Project Overview
We'll build a "Student Management System" that uses every control in the Windows Forms Toolbox.
Part 1: Project Setup
Step 1: Open Visual Studio
Open Visual Studio 2022 from your Start Menu or Desktop shortcut.
Step 2: Create New Project
- Click "Create a new project"
- Search for "Windows Forms App"
- Select "Windows Forms App (.NET Framework)"
- Click "Next"
Project Name: StudentManager
Location: C:\Users\YourName\Documents\Projects\
Framework: .NET 8.0
Step 3: Understand the Solution Explorer
After creating the project, look at the Solution Explorer on the right side. You'll see this structure:
📁 StudentManager/
├── 📁 Properties/
│ └── Resources.resx (Images, icons - we'll use this)
├── 📄 Form1.cs (Your code - we'll rename this)
├── 📄 Form1.Designer.cs (⚠️ DO NOT TOUCH this file!)
├── 📄 Program.cs (Entry point - don't change)
├── 📄 App.config (Settings - don't change)
└── 📄 StudentManager.csproj (Project file)
Form1.Designer.cs is auto-generated.
NEVER edit it manually!
Step 4: Rename Form1 to MainForm
- In Solution Explorer, right-click on
Form1.cs - Select "Rename"
- Change it to MainForm.cs
- Press Enter
- When asked, click "Yes" to rename all references
MainForm.cs in Solution Explorer.
Part 2: Basic Controls
Step 5: Open the Form Designer
Double-click on MainForm.cs in Solution Explorer to open the
form designer. You should see a blank form.
Step 6: Add Controls (Drag from Toolbox)
IMPORTANT: For each control, drag it from the Toolbox onto the form. DO NOT type code - the designer will handle everything!
MainForm.Designer.cs file.
Add these controls in order:
| # | Control | Name | Text/Properties | Where to Find |
|---|---|---|---|---|
| 1 | Label | lblTitle |
"Student Manager" | Toolbox → Common Controls |
| 2 | TextBox | txtFirstName |
"" | Toolbox → Common Controls |
| 3 | TextBox | txtLastName |
"" | Toolbox → Common Controls |
| 4 | Button | btnSave |
"Save Student" | Toolbox → Common Controls |
| 5 | CheckBox | chkActive |
"Active" | Toolbox → Common Controls |
| 6 | RadioButton | rbMale |
"Male" | Toolbox → Common Controls |
| 7 | RadioButton | rbFemale |
"Female" | Toolbox → Common Controls |
| 8 | ComboBox | cmbCourse |
Items: Math, Science, History | Toolbox → Common Controls |
| 9 | ListBox | lstStudents |
Items: (empty for now) | Toolbox → Common Controls |
| 10 | CheckedListBox | clbHobbies |
Items: Reading, Sports, Music | Toolbox → Common Controls |
Part 3: Container Controls
Step 7: Add Container Controls
| # | Control | Name | Properties | Where to Find |
|---|---|---|---|---|
| 11 | GroupBox | grpPersonalInfo |
Text: "Personal Information" | Toolbox → Containers |
| 12 | Panel | pnlButtons |
Dock: Bottom | Toolbox → Containers |
| 13 | SplitContainer | splitContainer |
Orientation: Vertical | Toolbox → Containers |
| 14 | TableLayoutPanel | tblLayout |
2 columns, 5 rows | Toolbox → Containers |
| 15 | DataGridView | dgvStudents |
Dock: Fill | Toolbox → Data |
| 16 | ListView | lvStudents |
View: Details | Toolbox → Common Controls |
Part 4: Specialized Controls
Step 8: Add Specialized Controls
| # | Control | Name | Properties | Where to Find |
|---|---|---|---|---|
| 17 | DateTimePicker | dtpBirthDate |
Format: Short | Toolbox → Common Controls |
| 18 | PictureBox | pbProfile |
SizeMode: Zoom | Toolbox → Common Controls |
| 19 | ImageList | imgList |
Images: Add icons (click the ... button) | Toolbox → Components |
| 20 | RichTextBox | rtbNotes |
"" | Toolbox → Common Controls |
| 21 | WebBrowser | webBrowser |
Navigate to "about:blank" | Toolbox → Common Controls |
| 22 | Timer | timerClock |
Interval: 1000 (Enabled: false) | Toolbox → Components |
| 23 | LinkLabel | llHelp |
"Need Help?" | Toolbox → Common Controls |
Part 5: Menus & Dialogs
Step 9: Add Menus & Dialogs
| # | Control | Name | Properties | Where to Find |
|---|---|---|---|---|
| 24 | MenuStrip | menuStrip |
Add: File, Edit, Help | Toolbox → Menus & Toolbars |
| 25 | ToolStrip | toolStrip |
Add buttons: New, Save, Print | Toolbox → Menus & Toolbars |
| 26 | NotifyIcon | notifyIcon |
Icon: Set (click ... to choose) | Toolbox → Components |
| 27 | SaveFileDialog | saveFileDialog |
Filter: "Text files|*.txt" | Toolbox → Dialogs |
| 28 | PrintDocument | printDocument |
- | Toolbox → Printing |
| 29 | PrintPreviewDialog | printPreviewDialog |
- | Toolbox → Dialogs |
Part 6: Write the Code
Step 10: Open MainForm.cs
Now we'll write the code. Double-click on MainForm.cs
in Solution Explorer (not the designer file).
Step 11: Add the Code
Copy and paste the code below into MainForm.cs.
11a. Add the Student Class
11b. Add the Data Store
11c. Add the Form Load Code
11d. Add the Save Button Click
11e. Add the Timer Tick
11f. Add the Full Code (All Together)
Part 7: Run the Project
Step 12: Run and Test
- Press F5 to run the project
- Test adding students with all controls
- Test the menu items (File, Edit, Help)
- Test the ToolStrip buttons
- Test printing
- Verify everything works
All 29 Controls Used
You have successfully used every control from the Toolbox:
- Label
- TextBox
- Button
- CheckBox
- RadioButton
- ComboBox
- ListBox
- CheckedListBox
- GroupBox
- Panel
- SplitContainer
- TableLayoutPanel
- DataGridView
- ListView
- DateTimePicker
- PictureBox
- ImageList
- RichTextBox
- WebBrowser
- Timer
- LinkLabel
- MenuStrip
- ToolStrip
- NotifyIcon
- SaveFileDialog
- PrintDocument
- PrintPreviewDialog
- PageSetupDialog
- PrintDialog