我正在尝试获取的关键,SelectedItem
但ComboBox
不知道如何获取我所做的代码,
void CboBoxSortingDatagridview(ComboBox sender)
{
foreach (var v in DictionaryCellValueNeeded)
{
if (!DictionaryGeneralUsers.ContainsKey(v.Key) && v.Value.RoleId == Convert.ToInt32(((ComboBox)sender).SelectedItem)) // here getting value {1,Admin} i want key value which is 1 but how?
{
DictionaryGeneralUsers.Add(v.Key, (GeneralUser)v.Value);
}
}
dataGridViewMain.DataSource = DictionaryGeneralUsers.Values;
}
我用这种方式绑定了组合框,
cboRolesList.DataSource = new BindingSource(dictionaryRole, null);
cboRolesList.DisplayMember = "Value";
cboRolesList.ValueMember = "Key";