Hello Guys,
Is there any way in a combobox to find the value and display the result.
in a combobox by the value
I have combobox cmbCategory bound to tabledata i.e.
cmbCategory.DisplayMember = "categoryName";
cmbCategory.ValueMember = "categoryID";
in table Category i store the value as categoryID int, categoryName as varchar
as this combobox is on employee Entry Form. i want to modify particular employee record
for that when i pickup employee record from database through datareader categoryID
is in value based like 1 or 2.
I want to now load cmbCategory according to value ie 2 and display related categoryName
Please help me.
Loading
Ranjit PowarPosted Sep 4, 2015, 3:32 AM
samar jeetPosted Sep 4, 2015, 3:02 AM
Rakesh KaushikPosted Mar 13, 2013, 6:07 AM
i told u that my combobox bound to tabledata.
and i want to search integer value which is bound by value member of tabledata.
either i am not able to make u understand my situation or you r also just guessing.
Animesh DattaPosted Mar 13, 2013, 3:34 AM
cmbCategory.Text = "Textvalue";
it will automatically select the index .
Rakesh KaushikPosted Mar 13, 2013, 3:08 AM
sorry for not informing that its a windows application and FindByValue function is not available here.
Animesh DattaPosted Mar 13, 2013, 1:58 AM
cmbCategory.SelectedIndex = cmbCategory.Items.IndexOf(cmbCategory.Items.FindByText(TextValue));
and ff you want to to select the category by its value then code is
cmbCategory.SelectedIndex = cmbCategory.Items.IndexOf(cmbCategory.Items.FindByValue(value));
thank you