Presentation is loading. Please wait.

Presentation is loading. Please wait.

Controls in C++/CLI (2) CheckBox RadioButton GroupBox ListBox.

Similar presentations


Presentation on theme: "Controls in C++/CLI (2) CheckBox RadioButton GroupBox ListBox."— Presentation transcript:

1 Controls in C++/CLI (2) CheckBox RadioButton GroupBox ListBox

2 Controls in C++/CLI (2) CheckBox (Property: Text, Checked, CheckState (checked/unchecked/indeterminate) ; Event: Clicked, CheckedChanged, CheckStateChanged) Multiple choices RadioButton (Property: Text, Checked; Event: Clicked, CheckedChanged) Single choice in one container

3 Example 1 Start from the last project TestCheck CheckBox
Remove TextBox CheckBox Dialog Box: Add three CheckBoxes for CS415, CS425, CS435; Names to be cbCS415, cbCS425, cbCS435 Add variables for inputs, and constructor Handle Click events to get input Form1: Invoke dialog box Get/use data

4 Example 2 Start from the last project TestCheck RadioButton:
Remove TextBox RadioButton: Dialog Box: Add four RadioButtons for Freshman, Sophomore, Junior, and Senior; Names to be rbFreshman, rbSophomore, rbJunior, and rbSenior Add variables for inputs, and constructor Handle Click events to get input Form1: Invoke dialog box Get/use data

5 Controls in C++/CLI (2) GroupBox
Group RadioButtons, will allow multiple in a form -- each in one group

6 Example 3 GroupBox: Start from the Dialog example Dialog Box:
Add two GroupBoxes for “years in school” and “study habits”; change the Text And Name accordingly, e.g, Names to be gbYears and gbStudy; Add RadioBottuns to each GroupBox: “years in school” to have Freshman, Sophomore, Junior, and Senior; and “study habits” to have night owl and early bird; change the Text And Name accordingly; Add variables for inputs, and constructor Handle Click events to get input Form1: Invoke dialog box; Get/use data (more data and displays)

7 Controls in C++/CLI (3) ListBox (Property: SelectionMode, Items, SelectedItem, SelectedIndex, SelectedItems, SelectedIndices; Event: SelectedIndexChanged) Show a collection of values, each with index, scrollable; Select one or more items, event SelectionMode (None, One, MultiSimple, and MultiExtended) please see

8 Items (ObjectCollection, add, remove, )
SelectedIndex (Int32, zero-based index) SelectedIndices (a collection of zero-based indices); SelectedItem (nullptr value if not actually selected), SelectedItems Event: SelectedIndexChanged

9 An Example (1) Draft a design…. Form1 and myDialog Classes
Variables, methods Components, event handlers Collections

10 An Example (2) Start from Form1 Add Label, Text “Name:”, Name “label1”
Add ListBox, Name “nameList”, SelectionMode “one”; Add three Buttons for “Add”, “Delete” and Edit”; Name bnAdd, bnDelete, bnEdit; add click event handlers, bnAdd_Click, bnDelete_Click, bnEdit_Click; Add a form for MyDialog Add Label, Text “Enter Name:”; Add TextBox, Name myTextBox; Add two buttons for “OK” and “Cancel”, Name as bnOK, bnCancel; add click events of bnOK_Click and bnCancel_Click; Write handler methods; set DialogResult for each; Set MyDialog’s AcceptButton and CancelButton;


Download ppt "Controls in C++/CLI (2) CheckBox RadioButton GroupBox ListBox."

Similar presentations


Ads by Google