VISUAL C# CONTROLS (OBJECTS)
-
Button: It is the control that makes a subprogram run when clicked.
-
Textbox: It allows us to get information from the user. The user can enter the desired information by clicking here. Also called text box.
-
Label: It is used to inform the user or to show results. The user cannot change the content of the label.
-
Checkbox: Allows the user to make a selection. No selection and multiple selections are allowed.
-
Radiobutton: Allows the user to make a selection. Only one of the radio buttons in the same group can be selected.
-
Combobox: (Drop-down list) It is a drop-down list that allows selection when clicked.
-
Listbox: It is a list that allows the user to make a selection. The difference from the combobox is that it is always on and multiple selections can be made when allowed.
-
CheckedListBox: It is an analogue of the Listbox control. Each element has a checkbox next to it and the user can select the desired boxes.
-
Timer: Allows a subprogram to run at intervals specified in milliseconds. For example, when the interval is 5000 ms, ie 5 seconds, the desired subprogram is run every 5 seconds and the operations written in it are repeated.
FEATURES OF CONTROLS
Operations are performed using the properties of controls in visual programming languages. The properties of the controls can be changed using the "properties" panel while designing. At the same time, we can change these properties with the commands we write.
Properties are attributes specific to the appearance, placement, or behavior of controls. For example, the Text property of a Button control allows us to access the text written on it.
Replacing Controls and Properties with code:
If the property of a control is to be changed by code, always the name of the control, followed by a period (.) and the name of the property.
For example, to change the enabled property of button1. It should be written as enabled=false.
If the name or property of the control is not written, the program will not understand what to operate with.
This can be compared to that of everyday life.
Michael.HairColor = Black;
Victor.weight= 55;
Hans.height = 180;
In Visual C#, some features are common to all controls. Examples of these are the following:
Some of the common features of the controls are:
-
Name: Each control has a name and is specified by the name property. The same name cannot be given to more than one control. For example, if we rename the control "label1" to "result", we should use this control with this name everywhere:
result.Text="Information Technology";
-
Text : Specifies the text that will appear above or inside that control. For example, the text on the button or the text inside the text box can be changed with this feature.
Button1.Text="CALCULATE";
TextBox1.Text="123";
Label1.Text="Welcome.";
-
Enabled : It can take two values , True and False . Its default value is True. When set to false, the object appears on the screen, but cannot be clicked by the user and its content cannot be changed. (Enabled - Disabled)
-
Size Properties (Width and Height): The word size means size, width means width, height means height. The width or height of the selected control can be adjusted by specifying it in pixels.
k1.width=300;
k1.height=50;
-
Backcolor: Used to change the background color of the control.
-
Forecolor: Used to change the foreground color of the control.
k1.ForeColor= Color.Yellow;
-
Visible: (Visibility) Makes a control visible or hidden. A value of “true” makes the control visible and a value of “false” makes it hidden.
k1.visible=false;
k1.visible=True;
using visual c# controls and properties, changing properties of visual c# controls, using textbox, how to use controls and properties in visual c#
EXERCISES
There are no examples related to this subject.
Read 881 times.