简体   繁体   中英

How To Get Id on combobox dropdown

I am making a Windows application and i have a combo box that will let the user type text and when user select text from autocomplete list id is not selected

my code :

  Customer.DropDownStyle = ComboBoxStyle.DropDown;

  DataTable dt = Globale.ReturnTable("SELECT Id, [NAME] FROM ACTM WHERE (DBCR = 'D') ORDER BY [NAME]");

  Customer.DataSource = dt;
  Customer.ValueMember = "Id";
  Customer.DisplayMember = "Name";
  Customer.AutoCompleteMode = AutoCompleteMode.Suggest;
  Customer.AutoCompleteSource = AutoCompleteSource.ListItems;
  Customer.SelectedIndex = -1;

i need id from name from ComboBoxStyle.DropDown not from dropdowlist

i need id from name from ComboBoxStyle.DropDown not from dropdowlist

ComboBoxStyle.DropDown is enum, so you can cast it

int id= (int)ComboBoxStyle.DropDown;

or if you need to find Customer ComboBoxStyle id

int id= (int)Customer.DropDownStyle;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM