Download presentation
Presentation is loading. Please wait.
Published byHarvey Ray Modified over 9 years ago
1
Dr Dat Tran - Week 1 Lecture Notes 1 Windows Forms Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences & Engineering
2
Dr Dat Tran - Week 1 Lecture Notes 2 VS.NET 2005 Start Page
3
Dr Dat Tran - Week 1 Lecture Notes 3 Windows Application
4
Dr Dat Tran - Week 1 Lecture Notes 4 Windows Application Project
5
Dr Dat Tran - Week 1 Lecture Notes 5 Form Properties
6
Dr Dat Tran - Week 1 Lecture Notes 6 Build & Debug Project
7
Dr Dat Tran - Week 1 Lecture Notes 7 Program.cs File
8
Dr Dat Tran - Week 1 Lecture Notes 8 MainForm.Designer.cs File
9
Dr Dat Tran - Week 1 Lecture Notes 9 Change Some Properties Try StartPosition & Location properties
10
Dr Dat Tran - Week 1 Lecture Notes 10 StartPosition - FormBorderStyle CentreParent only for modal dialogs (to prevent multi-monitor confusion) CentreScreen only for the main form or a splash screen WindowsDefaultLocation for everything else, to prevent windows from appearing on top of one another FixedDialog only for modal dialog boxes FixedSingle only for the main form None for splash screen Sizable for everything else, almost all forms in an application should be resizable
11
Dr Dat Tran - Week 1 Lecture Notes 11 Write Code in Program.cs
12
Dr Dat Tran - Week 1 Lecture Notes 12 Write Code in MainForm.Designer.cs
13
Dr Dat Tran - Week 1 Lecture Notes 13 Add a New Form At design time At run time Double-click on the form to add the Load event handler and modify it as follows Try ShowDialog()
14
Dr Dat Tran - Week 1 Lecture Notes 14 Example: partial class public partial class MainForm : Form public partial class MainForm : Form { public MainForm() { public MainForm() { InitializeComponent(); InitializeComponent(); } private void MainForm_Load(object sender, EventArgs e) { private void MainForm_Load(object sender, EventArgs e) { f2.ShowDialog(); f2.ShowDialog(); } } public partial class MainForm : Form public partial class MainForm : Form { Form f2 = new Form(); Form f2 = new Form(); }
15
Dr Dat Tran - Week 1 Lecture Notes 15 Message Box
16
Dr Dat Tran - Week 1 Lecture Notes 16 Use DialogResult private void MainForm_Load(object sender, EventArgs e) { DialogResult ds = MessageBox.Show("Hello World", "PGUI", DialogResult ds = MessageBox.Show("Hello World", "PGUI", MessageBoxButtons.YesNoCancel); MessageBoxButtons.YesNoCancel); if (ds == DialogResult.Yes) if (ds == DialogResult.Yes) { f2.Text = "Yes"; f2.Text = "Yes"; f2.ShowDialog(); f2.ShowDialog(); } if (ds == DialogResult.No) if (ds == DialogResult.No) { f2.Text = "No"; f2.Text = "No"; f2.ShowDialog(); f2.ShowDialog(); }}
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.