-
The drop-down box contains multiple items, and the text that can read one of the items in the drop-down box (n represents the index).
For example, the textual relationship between the index and the drop-down box text is as follows:
0 abc1 doc
2 ppt then the obtained text is abc, then the obtained text is doc, and so on.
If you want to get the currently selected item of the combobox, you can use : or:
-
If you want to read and write down the drop-down text use.
When the drop-down arrow is clicked, a dropdown event is raised.
private void combobox1_dropdown(object sender, eventargs e)
foreach (var item in
Used when you want to read the data in the drop-down list.
-
Just get the value attribute of that control.
-
string value;Only variables are stored.
int index = ;The index of the item that was selected.
value = ;Get the value.
-
WinForm or Webform?
Use DropDownList or ComboBox's SelectedItem or SelectValue
-
I'm referring here. .net is not winform, the principle is the same.
dropdownlist1 is the drop-down box object.
-
That's it (cmb changed to drop-down box control name).
-
var parents = _;
Fields that are displayed to the user.
classname";
The field that is passed to the database after selection.
classid";
Bind data to the drop-down box.
parents;
The selected text content is displayed in the label, as follows:
private void combobox1_selectionchangecommitted(object sender, eventargs e)
-
The selected text content is displayed in the label.
Come,** as follows: Inside.
private void combobox1_selectionchangecommitted(object sender, eventargs e)
-
The text content selected by the combobox.
Just right.
-
get the data set that needs to be bound from the database copy baivar parents = ;
Fields that are displayed for DU users.
classname";
Select the field that is passed to the database.
classid";
Bind the data to the drop-down box.
parents;
I read your second paragraph**.
Didn't get a value for this line**? It doesn't feel like it should be;
-
That's it. The selecttext property represents the highlighted text you selected with the mouse.
-
1. First of all, we will create a new key to a winform application, and then on the interface, place a drop-down box.
2. In the CS class, the value is bound to the drop-down box, which is used to display the effect.
3. Go back to the form interface, select the drop-down box, and in the properties panel, select the property dropdownheight, which is the property of the height of the drop-down box.
4. First, we set the height of the drop-down box to 200, and then, we debug the program to see the display effect.
5. Then, we close the interface and set the value of this property to 100.
6. After the setting is completed, let's restart it to see the effect.
7. According to the comparison of the two times, we can find that the height set by this attribute is different, and the height displayed in the drop-down box is different.
-
Get the value of the drop-down list box in c as follows:
using system;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
public partial class form1 : formpublic form1()
initializecomponent();
private void button1_click(object sender, eventargs e)=;
-
Landlord, yes, if you use the list box, the number of items entered exceeds the number displayed in the list box, and the scroll bar will automatically appear. If it is a combobox, find the items property in its properties window, and open it"String aggregators"Enter it and you're done, enter the wrap.
-
Use the selectedIndex property of the combobox to get the number of the selected item (0 starts with -1 is unchecked).
selectedtext attribute to get information about the selected string.
text attribute to get the selected or user-entered string information.
If you want to get a collection of all the list boxes. then access the item() property.
It can be passed. add, remove, etc.
Each element is accessed via item(i).
If you are in the transformation stage, you can directly find the items property in its properties window and open it"String aggregators"Enter it and you're done, enter the wrap.
Example**. using system;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
namespace windowsformsapplication1private void button1_click(object sender, eventargs e)
Hope it helps.
-
The property of each drop-down box has an id that can be judged, and if you are binding, then it will not work, and you can only get the value of the current text box after you select it.
-
int n = 0;Index.
string str = "word";Words that need to be judged.
if( == str)else
-
Don't know what you need? Can you say that you believe in the point" I feel that you should not be a simple value.
-
dllst .datasource = list; = "field"; = "field";This allows you to set the displayed and hidden values for the drop-down list box. You try it.
using system;
using ; >>>More