Chapter ii c#(building a user interface)
-
Upload
chhom-karath -
Category
Education
-
view
170 -
download
2
Transcript of Chapter ii c#(building a user interface)
![Page 1: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/1.jpg)
Working with Form
Chapter II
![Page 2: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/2.jpg)
Message Boxes
• A message box is a special dialog box used to display a piece of information to user.– MessageBox class – EX:
MessageBox.Show("Hello, how are you?","My SMS");MessageBox.Show("Welcome to the Wonderful World of Visual C#","Visual C# Tutorials", MessageBoxButtons.OKCancel);
MessageBox.Show("Your order appears to be correct" + "\nAre you ready to provide your credit card information?", "Customer Order Processing", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
![Page 3: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/3.jpg)
EX:MessageBox.Show("Your order appears to be correct" + "\nAre you ready to provide your credit card information?",
"Customer Order Processing", MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);NOTE:Button1 , Button2 , Button3
![Page 4: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/4.jpg)
private void txtNumber_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar >= 'a' && e.KeyChar <= 'z') || (e.KeyChar >= 'A' && e.KeyChar <= 'Z') || e.KeyChar==' ') { e.Handled =true; } }
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if ((e.KeyChar >= '0' && e.KeyChar <= '9')) { e.Handled = true; } }Note: || (e.KeyChar == (char)Keys.Back)
![Page 5: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/5.jpg)
1. Button2. OpenFileDialog Control3. Picture Box
![Page 6: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/6.jpg)
this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Normal; this.WindowState = FormWindowState.Maximized;EX:foreach (Control c in this.Controls) { TextBox t = c as TextBox; ComboBox cbo = c as ComboBox;
if (t != null) { t.Text = " "; } else if (cbo != null) { cbo.Text = " "; } }
![Page 7: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/7.jpg)
Radiobutton and CheckBox
![Page 8: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/8.jpg)
ListBox
![Page 9: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/9.jpg)
Creating Timers
![Page 10: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/10.jpg)
Creating Tabbed Dialog Boxes
![Page 11: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/11.jpg)
Creating List View
![Page 12: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/12.jpg)
1. Adding Menu Items2. Creating Checked Menu Items3. Assigning Shortcut Keys4. Using the Toolbar Control
![Page 13: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/13.jpg)
Creating MDI FormsAll the projects you've created so far have been single-document interface (SDI) projects. In SDI programs, every form in the application is a peer of all other forms; no intrinsic hierarchy exists between forms. C# also lets you create multiple-document interface (MDI) programs. A MDI program contains one parent window (also called a container) and one or more child windows. A classic example of a MDI program is Microsoft Word 95 (200 behaves slightly different, depending on how it's set up).
![Page 14: Chapter ii c#(building a user interface)](https://reader038.fdocuments.net/reader038/viewer/2022103105/58f309b51a28abcd0e8b4581/html5/thumbnails/14.jpg)
this.Hide();Form2 frm2 = new Form2();frm2.Show();