RadioButton
Allows the user to select a single option from group of available options.
Default event: CheckedChanged which is fired when the radio button is checked or unchecked.
Example code to display selection status of radiobutton on a label:
Default event: CheckedChanged which is fired when the radio button is checked or unchecked.
Example code to display selection status of radiobutton on a label:
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
label1.Text = "Radio
1 Selected";
}
else {
label1.Text = "Radio
1 Unselected";
}
}
PictureBox
Used to display image on the form.
To set static image:
Click on smart tag – Select local resource – import to select an image to display image.
Import option is used to set image without copying image to project location. So, with the setup image will not be carried away. So, next option project resource is recommend.
Click on smart tag – Select project resource file – import to select an image to display image by copying it into Resources folder in your project.
Default event: Click which is fired when user click on the picture box.
Example code to change the image when user click on the picture box:
To set static image:
Click on smart tag – Select local resource – import to select an image to display image.
Import option is used to set image without copying image to project location. So, with the setup image will not be carried away. So, next option project resource is recommend.
Click on smart tag – Select project resource file – import to select an image to display image by copying it into Resources folder in your project.
Default event: Click which is fired when user click on the picture box.
Example code to change the image when user click on the picture box:
private void pictureBox1_Click(object sender, EventArgs e)
{
pictureBox1.ImageLocation=@"C:\Users\bc250150\Pictures\Flower.jpg";
}
NumericUpDown
Displays a single numeric value that can be that the user can increment or decrement using up and down buttons on the control.
Default event: ValueChanged which is fired everytime when user changes the value.
Properties:
Increment: Indicates the amount to increment or decrement on each button click.
Minimum and Maximum: Indicates the minimum and maximum value for the numeric up-down control.
ThousandsSeparator: Set to true to add separator between every 3 digits.
Value: The current value of the numeric up-down control when it is loaded on the form.
Example code to display the selected value in label control:
Default event: ValueChanged which is fired everytime when user changes the value.
Properties:
Increment: Indicates the amount to increment or decrement on each button click.
Minimum and Maximum: Indicates the minimum and maximum value for the numeric up-down control.
ThousandsSeparator: Set to true to add separator between every 3 digits.
Value: The current value of the numeric up-down control when it is loaded on the form.
Example code to display the selected value in label control:
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
label1.Text = numericUpDown1.Value.ToString();
}
NotifyIcon
Displays a notification icon in the notification area, in the bottom right side of the windows task bar, during runtime.
Adding icon:
Drag and drop Nofify icon control to your design page of the form.
It will be located in the bottom panel but not displayed on the design form.
Click on its smart tag.
Select Choose icon
Select a .ico from file which can be used an icon.
Run the application to see that icon displayed in the notification area.
Adding icon:
Drag and drop Nofify icon control to your design page of the form.
It will be located in the bottom panel but not displayed on the design form.
Click on its smart tag.
Select Choose icon
Select a .ico from file which can be used an icon.
Run the application to see that icon displayed in the notification area.
MonthCalendar
Displays a monthly calendar from which user can select a date.
Default event: DateChanged which is fired when user selected a date from the month calendar.
Properties:
Show Today: Set it to true for displaying today’s date in system at the bottom of the calendar.
Show TodayCircle Set it to true for displaying today’s date with a circle.
MinDate and MaxDate: To set the minimum and maximum date available in the calendar to select by the user.
MaxSelectionCount: The total number of days that can be selected by the user.
FirstDayOfWeek: To customize the calendar first day of the week.
Default event: DateChanged which is fired when user selected a date from the month calendar.
Properties:
Show Today: Set it to true for displaying today’s date in system at the bottom of the calendar.
Show TodayCircle Set it to true for displaying today’s date with a circle.
MinDate and MaxDate: To set the minimum and maximum date available in the calendar to select by the user.
MaxSelectionCount: The total number of days that can be selected by the user.
FirstDayOfWeek: To customize the calendar first day of the week.
MaskedTextBox
Used to take user inputs based on the given condition.
To set the condition for Masked textbox:
Click on smart tag – Select SetMask
You can select available predefined masking conditions or can write our own condtions.
Example: 000000000 for 10 digit numbers
Default event: MaskInputRejected which is fired when user entered an invalid input in masked textbox.
To set the condition for Masked textbox:
Click on smart tag – Select SetMask
You can select available predefined masking conditions or can write our own condtions.
Example: 000000000 for 10 digit numbers
Default event: MaskInputRejected which is fired when user entered an invalid input in masked textbox.
Example
code to clear text in masked textbox everytime when user enter invalid text:
private void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
{
maskedTextBox1.Text = "";
}
ListView
Used to display items under different groups.
Items can be displayed in one of the five
Adding items in ListView:
Click on smart tag – Edit Items – Add
Text property is used to add text to every item.
Example: A, B, C, 1,2, 3
Adding Groups in ListView:
Click on smart tag – Edit Groups – Add
Header property is used to add group header text to every group.
Example: Alphabets, Numbers
To group items into different groups
Make sure that you already created some groups and items
Click on smart tag – Edit Items
Select and item and use Group property to set a group for the selected item.
Items can be displayed in one of the five
Adding items in ListView:
Click on smart tag – Edit Items – Add
Text property is used to add text to every item.
Example: A, B, C, 1,2, 3
Adding Groups in ListView:
Click on smart tag – Edit Groups – Add
Header property is used to add group header text to every group.
Example: Alphabets, Numbers
To group items into different groups
Make sure that you already created some groups and items
Click on smart tag – Edit Items
Select and item and use Group property to set a group for the selected item.