More Related Content Similar to C++ Windows Forms L04 - Controls P3 (20) More from Mohammad Shaker (20) C++ Windows Forms L04 - Controls P36. TabPage-How to change, add
tabpages?
• If copying and pasting in the selected area like following …
what will happen?
21. ListBox - SelectionMode
• MultiSimple:
– No ctrl needed!
• MultiExtended:
– ctrl needed when selecting more that one
– Auto select changing
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();
}
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” );
}
}
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,
46. 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";
}
}
47. CheckedListBox
• So, we do this:
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
if (checkedListBox1->GetItemChecked(1) == true)
{
textBox1->Text = "WoW ";
}
}
49. CheckedListBox
• Now, let’s see this:
private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
checkedListBox1->Items->Add("Spanish");
}
sender,
51. CheckedListBox
• And ofcourse, we can do this!
private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
checkedListBox1->Items->Add(textBox1->Text);
}
sender,
59. RadioButton
• So, how to break the restriction and select more than one
radioButton?
There’s sth called the “GroupBox” from “Containers” section.
62. GroupBox
• Now, we can choose more than one RadioButton
• But we can only choose one RadioButton from “each”
GroupBox.