chapter ii c#(building a user interface)
TRANSCRIPT
Working with Form
Chapter II
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);
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
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)
1. Button2. OpenFileDialog Control3. Picture Box
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 = " "; } }
Radiobutton and CheckBox
ListBox
Creating Timers
Creating Tabbed Dialog Boxes
Creating List View
1. Adding Menu Items2. Creating Checked Menu Items3. Assigning Shortcut Keys4. Using the Toolbar Control
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).
this.Hide();Form2 frm2 = new Form2();frm2.Show();