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

Animesh DattaRank #9,921 · 201 reputationPosted Mar 12, 2013, 9:58 PM EDT
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
Rakesh Kaushik29 reputationPosted Mar 12, 2013, 11:08 PM EDT
sorry for not informing that its a windows application and FindByValue function is not available here.
Animesh DattaRank #9,921 · 201 reputationPosted Mar 12, 2013, 11:34 PM EDT
cmbCategory.Text = "Textvalue";
it will automatically select the index .
Rakesh Kaushik29 reputationPosted Mar 13, 2013, 2:07 AM EDT
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.
samar jeet40 reputationPosted Sep 3, 2015, 11:02 PM EDT
Ranjit PowarRank #553 · 4.4K reputationPosted Sep 3, 2015, 11:32 PM EDT