Combobox in C# i Need to fill two value in combo box -


I have a problem with the C # code for the combo box. My code is here

  CmbProjectName Items.Clear (); If (obds.Tables.Count & gt; 0 and amp; amp; and obds.Tables [0] .rav count * gt; {for (int iCount = 0; iCount & lt; obds.Tables [0] .Rows.Count; ICount ++) {cmbProjectName.Items.Add (obds.Tables [0] .ows [iCount] ["Project_Name"]. ToString ()); }}  

Add value to the combo box but I will add the indicator of this item for further operation on other items, please notify me ...

The solution for JAEP will work by using the class. There is another way to bind a dictionary, you do not have to make extra classes here.

The code will be down in your case. Replace ICount with the index you want.

cmbProjectName.Items.Clear (); Dictionary & lt; Int, string & gt; ProjectsDictionary = New Dictionary & lt; Int, string & gt; (); If (obds.Tables.Count & gt; 0 and amp; amp; and obds.Tables [0] .rav count * gt; {for (int iCount = 0; iCount & lt; obds.Tables [0] .Rows.Count; ICount ++) {projectsDictionary.Add (iCount, obds.Tables [0] .ows [iCount] ["Project_Name"]. ToString ()); }} CmbProjectName.DataSource = new binding source (projects, zero); CmbProjectName.DisplayMember = "value"; CmbProjectName.ValueMember = "key";

Code to retrieve the key or value.

  string value = ((keywallpayer & lt; int, string & gt;) cmbProjectName.SelectedItem). value; Int key = ((KeyValuePair & lt; int, string & gt;) cmbProjectName.SelectedItem) .key;  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -