SlideShare a Scribd company logo
C++.NET
Windows Forms Course
L04 -Controls Part 3

Mohammad Shaker
mohammadshakergtr.wordpress.com
C++.NET Windows Forms Course
@ZGTRShaker
TabPage
TabPage (Design Time)
• Design Time …
TabPage (Runtime)
• Runtime …
TabPage-How to change, add
tabpages?
• At design time …
– Copy  paste restrictions
TabPage-How to change, add
tabpages?
• If copying and pasting in the selected area like following …
what will happen?
TabPage-How to change, add
tabpages?
• If copying and pasting in the selected area like following
TabPage-How to change, add
tabpages?
• It should be like here …
TabPage-How to change, add
tabpages?
• Now, at Runtime … it looks like …
TabPage-changing names
TabPage-changing names
TabPage-changing names
ListBox
ListBox (Design time)
• Design time
ListBox (Runtime)
• Runtime
ListBox
ListBox
ListBox
• Let’s have the following small project …
ListBox
ListBox - SelectionMode
• One:
– Can only choose one at a time
ListBox - SelectionMode
• MultiSimple:
– No ctrl needed!

• MultiExtended:
– ctrl needed when selecting more that one
– Auto select changing
ListBox
ListBox - Coding
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++?
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();
}
ListBox - Coding
• When changing the course …
CheckBox
CheckBox
• CheckBoxes
– Set of non-connected controls
– Can choose one or more “checkBox”
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” );
}
}
CheckBox
CheckBox

private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
if (checkBox1->Checked == true )
{
MessageBox::Show("You chose " + sender->ToString() );
}
}
CheckBox

private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
if (checkBox1->Checked == true )
{
MessageBox::Show("You chose " + e->ToString() );
}
}
CheckedListBox
CheckedListBox
CheckedListBox
• Set of connected “checkBox”es
CheckedListBox
CheckedListBox
CheckedListBox
CheckedListBox
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
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,
C++ Windows Forms L04 - Controls P3
C++ Windows Forms L04 - Controls P3
C++ Windows Forms L04 - Controls P3
Why?!
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";
}
}
CheckedListBox
• So, we do this:
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
if (checkedListBox1->GetItemChecked(1) == true)
{
textBox1->Text = "WoW ";
}
}
C++ Windows Forms L04 - Controls P3
CheckedListBox
• Now, let’s see this:
private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
checkedListBox1->Items->Add("Spanish");
}

sender,
C++ Windows Forms L04 - Controls P3
CheckedListBox
• And ofcourse, we can do this!
private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
checkedListBox1->Items->Add(textBox1->Text);
}

sender,
CheckedListBox
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
if (checkedListBox1->Items[0]->ToString() == "English")
{
textBox1->Text = "WoW ";
}
}
CheckedListBox
RadioButton
C++ Windows Forms L04 - Controls P3
RadioButton
• “Radio button”s
– Set of related “item”s
– Can choose only one “at a time”
RadioButton
• Only one can be chosen at a time
RadioButton
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e)
{
if (radioButton1->Checked == true )
MessageBox::Show("I wanna drink some water");
}
RadioButton
• So, how to break the restriction and select more than one
radioButton?
There’s sth called the “GroupBox” from “Containers” section.
GroupBox
GroupBox
GroupBox
• Now, we can choose more than one RadioButton
• But we can only choose one RadioButton from “each”
GroupBox.
That’s it for today!

More Related Content

PDF
C++ Windows Forms L03 - Controls P2
PDF
C++ Windows Forms L06 - Utlitity and Strings
PDF
C++ Windows Forms L02 - Controls P1
PDF
C++ Windows Forms L11 - Inheritance
PDF
C++ Windows Forms L05 - Controls P4
PDF
C++ Windows Forms L10 - Instantiate
PDF
C++ Windows Forms L09 - GDI P2
PDF
C++ Windows Forms L07 - Collections
C++ Windows Forms L03 - Controls P2
C++ Windows Forms L06 - Utlitity and Strings
C++ Windows Forms L02 - Controls P1
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L05 - Controls P4
C++ Windows Forms L10 - Instantiate
C++ Windows Forms L09 - GDI P2
C++ Windows Forms L07 - Collections

What's hot (20)

PDF
The Ring programming language version 1.5.2 book - Part 7 of 181
PPT
VB Dot net
PDF
The Ring programming language version 1.5.1 book - Part 6 of 180
PDF
The Ring programming language version 1.5.3 book - Part 7 of 184
PPTX
Apache Flink Training: DataStream API Part 2 Advanced
PDF
The Ring programming language version 1.8 book - Part 7 of 202
PDF
Writing Domain-Specific Languages for BeepBeep
PDF
The Ring programming language version 1.3 book - Part 83 of 88
DOCX
Dotnet 18
PDF
Bot builder v4 HOL
PDF
Mocks introduction
PPTX
Apache Flink Training: DataSet API Basics
PDF
Chat application in java using swing and socket programming.
DOCX
.net progrmming part4
PDF
DOM-based Test Adequacy Criteria for Web Applications
PDF
Exploring Clojurescript
PDF
final project for C#
PDF
The Ring programming language version 1.7 book - Part 7 of 196
PDF
Chat Room System using Java Swing
The Ring programming language version 1.5.2 book - Part 7 of 181
VB Dot net
The Ring programming language version 1.5.1 book - Part 6 of 180
The Ring programming language version 1.5.3 book - Part 7 of 184
Apache Flink Training: DataStream API Part 2 Advanced
The Ring programming language version 1.8 book - Part 7 of 202
Writing Domain-Specific Languages for BeepBeep
The Ring programming language version 1.3 book - Part 83 of 88
Dotnet 18
Bot builder v4 HOL
Mocks introduction
Apache Flink Training: DataSet API Basics
Chat application in java using swing and socket programming.
.net progrmming part4
DOM-based Test Adequacy Criteria for Web Applications
Exploring Clojurescript
final project for C#
The Ring programming language version 1.7 book - Part 7 of 196
Chat Room System using Java Swing
Ad

Similar to C++ Windows Forms L04 - Controls P3 (20)

PDF
Intake 38 9
PPTX
Vs c# lecture1
PPSX
PPT
Session 1. Bai 1 ve winform
PPT
C# Tutorial MSM_Murach chapter-10-slides
PPT
PPTX
Vp lecture1 ararat
PDF
Delphi L02 Controls P1
DOCX
PDF
PDF
Intake 37 9
PPTX
Vs c# lecture2
PPTX
Vp lecture 4 ararat
PPTX
Windows form application_in_vb(vb.net --3 year)
PDF
Notes windows form controls gui applications
PDF
BCA IPU VB.NET UNIT-III
PPTX
lesson-9-Building-Windows-Form-Application.pptx
PDF
Test Bank for Starting Out With Visual Basic 2012, 6th Edition Gaddis, Irvine
PDF
Visual Basic IDE Introduction
PDF
Visual Basic IDE Intro.pdf
Intake 38 9
Vs c# lecture1
Session 1. Bai 1 ve winform
C# Tutorial MSM_Murach chapter-10-slides
Vp lecture1 ararat
Delphi L02 Controls P1
Intake 37 9
Vs c# lecture2
Vp lecture 4 ararat
Windows form application_in_vb(vb.net --3 year)
Notes windows form controls gui applications
BCA IPU VB.NET UNIT-III
lesson-9-Building-Windows-Form-Application.pptx
Test Bank for Starting Out With Visual Basic 2012, 6th Edition Gaddis, Irvine
Visual Basic IDE Introduction
Visual Basic IDE Intro.pdf
Ad

More from Mohammad Shaker (20)

PDF
12 Rules You Should to Know as a Syrian Graduate
PDF
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
PDF
Interaction Design L06 - Tricks with Psychology
PDF
Short, Matters, Love - Passioneers Event 2015
PDF
Unity L01 - Game Development
PDF
Android L07 - Touch, Screen and Wearables
PDF
Interaction Design L03 - Color
PDF
Interaction Design L05 - Typography
PDF
Interaction Design L04 - Materialise and Coupling
PDF
Android L05 - Storage
PDF
Android L04 - Notifications and Threading
PDF
Android L09 - Windows Phone and iOS
PDF
Interaction Design L01 - Mobile Constraints
PDF
Interaction Design L02 - Pragnanz and Grids
PDF
Android L10 - Stores and Gaming
PDF
Android L06 - Cloud / Parse
PDF
Android L08 - Google Maps and Utilities
PDF
Android L03 - Styles and Themes
PDF
Android L02 - Activities and Adapters
PDF
Android L01 - Warm Up
12 Rules You Should to Know as a Syrian Graduate
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Interaction Design L06 - Tricks with Psychology
Short, Matters, Love - Passioneers Event 2015
Unity L01 - Game Development
Android L07 - Touch, Screen and Wearables
Interaction Design L03 - Color
Interaction Design L05 - Typography
Interaction Design L04 - Materialise and Coupling
Android L05 - Storage
Android L04 - Notifications and Threading
Android L09 - Windows Phone and iOS
Interaction Design L01 - Mobile Constraints
Interaction Design L02 - Pragnanz and Grids
Android L10 - Stores and Gaming
Android L06 - Cloud / Parse
Android L08 - Google Maps and Utilities
Android L03 - Styles and Themes
Android L02 - Activities and Adapters
Android L01 - Warm Up

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
sap open course for s4hana steps from ECC to s4
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation_ Review paper, used for researhc scholars
MIND Revenue Release Quarter 2 2025 Press Release
A comparative analysis of optical character recognition models for extracting...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
sap open course for s4hana steps from ECC to s4
NewMind AI Weekly Chronicles - August'25-Week II
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
The Rise and Fall of 3GPP – Time for a Sabbatical?
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
Empathic Computing: Creating Shared Understanding
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
gpt5_lecture_notes_comprehensive_20250812015547.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Mobile App Security Testing_ A Comprehensive Guide.pdf

C++ Windows Forms L04 - Controls P3