chapter ii c#(building a user interface)

14
Working with Form Chapter II

Upload: chhom-karath

Post on 16-Apr-2017

170 views

Category:

Education


2 download

TRANSCRIPT

Page 1: Chapter ii c#(building a user interface)

Working with Form

Chapter II

Page 2: Chapter ii c#(building a user interface)

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)

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)

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)

1. Button2. OpenFileDialog Control3. Picture Box

Page 6: Chapter ii c#(building a user interface)

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)

Radiobutton and CheckBox

Page 8: Chapter ii c#(building a user interface)

ListBox

Page 9: Chapter ii c#(building a user interface)

Creating Timers

Page 10: Chapter ii c#(building a user interface)

Creating Tabbed Dialog Boxes

Page 11: Chapter ii c#(building a user interface)

Creating List View

Page 12: Chapter ii c#(building a user interface)

1. Adding Menu Items2. Creating Checked Menu Items3. Assigning Shortcut Keys4. Using the Toolbar Control

Page 13: Chapter ii c#(building a user interface)

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)

this.Hide();Form2 frm2 = new Form2();frm2.Show();