Beruflich Dokumente
Kultur Dokumente
Text property
determines what is displayed on the label
2. messageLabel.Visible
qtyTextBox
Text property
The current text being displayed or to be displayed.
To copy a TextBox to a Label.
outputLabel.Text = qtyTextBox.Text;
To display a text on the textBox
qtyTextBox = “1”;
Clear() method
Ability to clear itself.
Eg: qtyTextBox.Clear();
TextBox can also be cleared as shown:
qtyTextBox.Text = “”;
Focus() method
Ability to set the cursor to itself, to receive input from keyboard.
Eg: qtyTextBox.Focus();
Focus can be moved to next control by the TAB key.
Has focus
No focus
Text property
To display the caption of the CheckBox.
Usually set at design time.
Checked property
To indicate if the option is selected.
May set as a default, at design time.
Toggles when user clicks
2. malayCheckBox.Checked() = “false”;
GroupBox
Text property
Checked property
Text property
The caption of the RadioButton.
Checked property
To indicate if the option is selected.
May set as a default at design time.
Slide 2-21
2015 Oct 6FOOP
Radio Buttons ….cont
CheckedChanged event
Is triggered whenever the checked property is
changed either by mouse click or by program.
Codes in the CheckedChanged event handler is
automatically executed.
Image property
The graphic to be displayed.
Set using Properties window.
Or during run time, using Fromfile method eg:
logoPictureBox.Image =
Image.FromFile(“C:\\Graphics\\logo.bmp”); Note: double “\”
Visible property
to hide the picture box or show it.
Set using Properties window or program.
E.g. bluePictureBox.Visible = false;
Text property
Text property
The caption of the Button.
Set using the Properties window or in program.
E.g. enterButton.Text = “&Enter”;
Click event
When a user clicks a button, the Click event is invoked.
Slide 2-25
2015 Oct 6FOOP
Buttons Control..cont
Question: What does the button click event do?
private void onOffButton_Click(object sender, EventArgs e)
{ if (onOffButton.Text == “&ON”)
onOffButton.Text = “&OFF”;
else
onOffButton.Text = “&ON”;
//changing text does not cause a click event
}
Slide 2-26
2015 Oct 6FOOP
Access Keys
An access key is an underlined character in the text of a
button. A button "click" can be simulated by pressing the
ALT key + access key
An ampersand (&) before a letter in the Text property of
a button to create an access key
Set using Properties window
E.g. &OK (access key o: Alt + o)
E&xit (access key x: Alt + x)
Set by program.
E.g. exitButton.text = “E&xit”;
Select a Button
to be the
CancelButton
Slide 2-29
2015 Oct 6FOOP
ListBox and Combo Control
To display a list of items for user to make a selection.
Different between listBox and comboBox:
ComboBox has Dropdown style property.
Combo Box
List Box
That maximum
number of items that
a drop-down list can
display at one time
is set by property
MaxDropDownItems
.
Common Event
SelectedIndexChanged Generated when the selected index changes (such as when a different item
is selected). This is the default event when control is double clicked in the
designer.
Methods
Add method Use to add item into the list.
Example:comboBox1.Items.Add(“Hello”);
Clear method Use to empty the ComboBox list
Example: comboBox1.Items.Clear();
Picture
Radio
boxes
buttons
Check
box
Group
boxes Buttons
List box
Labels (only
appears after
use press Select an order and press “Delete” to delete the order
“confirm”
Press “Cancel” to remove all order (i.e. cancel everything).