C++ Windows Forms L04 - Controls P3

  • 277 views
Uploaded on

C++ Windows Forms L04 - Controls P3 of C++ Windows Forms Light Course

C++ Windows Forms L04 - Controls P3 of C++ Windows Forms Light Course

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
277
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
33
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. C++.NET Windows Forms Course L04 -Controls Part 3 Mohammad Shaker mohammadshakergtr.wordpress.com C++.NET Windows Forms Course @ZGTRShaker
  • 2. TabPage
  • 3. TabPage (Design Time) • Design Time …
  • 4. TabPage (Runtime) • Runtime …
  • 5. TabPage-How to change, add tabpages? • At design time … – Copy paste restrictions
  • 6. TabPage-How to change, add tabpages? • If copying and pasting in the selected area like following … what will happen?
  • 7. TabPage-How to change, add tabpages? • If copying and pasting in the selected area like following
  • 8. TabPage-How to change, add tabpages? • It should be like here …
  • 9. TabPage-How to change, add tabpages? • Now, at Runtime … it looks like …
  • 10. TabPage-changing names
  • 11. TabPage-changing names
  • 12. TabPage-changing names
  • 13. ListBox
  • 14. ListBox (Design time) • Design time
  • 15. ListBox (Runtime) • Runtime
  • 16. ListBox
  • 17. ListBox
  • 18. ListBox • Let’s have the following small project …
  • 19. ListBox
  • 20. ListBox - SelectionMode • One: – Can only choose one at a time
  • 21. ListBox - SelectionMode • MultiSimple: – No ctrl needed! • MultiExtended: – ctrl needed when selecting more that one – Auto select changing
  • 22. ListBox
  • 23. ListBox - Coding
  • 24. private: System::Void listBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { if (listBox1->SelectedIndex == 0) { textBox1->Text = "C++ Course is a course about c++!:D"; } } What’s will happen now? What will happen when selecting another option after selecting C++?
  • 25. ListBox - Coding • It’s a runtime error if selecting nothing and then pressing button2. Otherwise it works properly. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { textBox1->Text =listBox1->SelectedItem->ToString(); }
  • 26. ListBox - Coding • When changing the course …
  • 27. CheckBox
  • 28. CheckBox • CheckBoxes – Set of non-connected controls – Can choose one or more “checkBox”
  • 29. CheckBox private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (checkBox1->Checked == true ) { MessageBox::Show("You chose " + checkBox1->Text ); } } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (checkBox1->Checked == true ) { MessageBox::Show("You chose " + “English” ); } } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (checkBox1->Checked == true ) { MessageBox::Show("You chose English” ); } }
  • 30. CheckBox
  • 31. CheckBox private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (checkBox1->Checked == true ) { MessageBox::Show("You chose " + sender->ToString() ); } }
  • 32. CheckBox private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (checkBox1->Checked == true ) { MessageBox::Show("You chose " + e->ToString() ); } }
  • 33. CheckedListBox
  • 34. CheckedListBox
  • 35. CheckedListBox • Set of connected “checkBox”es
  • 36. CheckedListBox
  • 37. CheckedListBox
  • 38. CheckedListBox
  • 39. CheckedListBox
  • 40. CheckedListBox • Hierarchy … – System::Object System::MarshalByRefObject System.ComponentModel::Component System.Windows.Forms::Control System.Windows.Forms::ListControl System.Windows.Forms::ListBox System.Windows.Forms::CheckedListBox
  • 41. CheckedListBox • Let’s have the following code … private: System::Void button1_Click(System::Object^ System::EventArgs^ e) { if (checkedListBox1->SelectedIndex == 1 ) { textBox1->Text = "WOOOW"; } } sender,
  • 42. Why?!
  • 43. CheckedListBox • The same story goes with this: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (checkedListBox1->SelectedItem == "French" ) { textBox1->Text = "WOOOW"; } }
  • 44. CheckedListBox • So, we do this: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (checkedListBox1->GetItemChecked(1) == true) { textBox1->Text = "WoW "; } }
  • 45. CheckedListBox • Now, let’s see this: private: System::Void button1_Click(System::Object^ System::EventArgs^ e) { checkedListBox1->Items->Add("Spanish"); } sender,
  • 46. CheckedListBox • And ofcourse, we can do this! private: System::Void button1_Click(System::Object^ System::EventArgs^ e) { checkedListBox1->Items->Add(textBox1->Text); } sender,
  • 47. CheckedListBox private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (checkedListBox1->Items[0]->ToString() == "English") { textBox1->Text = "WoW "; } }
  • 48. CheckedListBox
  • 49. RadioButton
  • 50. RadioButton • “Radio button”s – Set of related “item”s – Can choose only one “at a time”
  • 51. RadioButton • Only one can be chosen at a time
  • 52. RadioButton private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if (radioButton1->Checked == true ) MessageBox::Show("I wanna drink some water"); }
  • 53. RadioButton • So, how to break the restriction and select more than one radioButton? There’s sth called the “GroupBox” from “Containers” section.
  • 54. GroupBox
  • 55. GroupBox
  • 56. GroupBox • Now, we can choose more than one RadioButton • But we can only choose one RadioButton from “each” GroupBox.
  • 57. That’s it for today!