Combox Selected Value

Posted by Bhupentiwari under Windows Forms on 3/3/2016 | Points: 10 | Views : 288 | Status : [Member] | Replies : 2
 

DataGridViewRow dgvRow = new DataGridViewRow();
DataGridViewTextBoxCell GradeID = new DataGridViewTextBoxCell();
GradeID.Value = mLub.GradeID;
iCount = iCount + 1;

DataGridViewTextBoxCell GradeName = new DataGridViewTextBoxCell();
GradeName.Value = mLub.GradeName;

// Combox box
DataGridViewComboBoxCell cmbLubOilSystemID = new DataGridViewComboBoxCell();


cmbLubOilSystemID.DataSource = olist;
cmbLubOilSystemID.ValueMember = "LubOilSystemID";
cmbLubOilSystemID.DisplayMember = "LubOilSystemName";


dgvRow.Cells.Add(GradeID);
dgvRow.Cells.Add(GradeName);
dgvRow.Cells.Add(cmbLubOilSystemID);

//Add to grid. set values.
dgvLubOilGrades.Rows.Add(dgvRow);


In the above code i am binding combobox from list.

I want to dynamically select value of combox

Thanks n Regards
Bhupendra Tiwari



Responses

Posted by: A2H on: 3/3/2016 [Member] [MVP] Silver | Points: 25

Up
0
Down
You can try with the below code
DataGridViewComboBoxCell cmbLubOilSystemID = new DataGridViewComboBoxCell();


cmbLubOilSystemID.DataSource = olist;
cmbLubOilSystemID.ValueMember = "LubOilSystemID";
cmbLubOilSystemID.DisplayMember = "LubOilSystemName";

cmbLubOilSystemID.Value = "Here provide the LubOilSystemID which you want as selected"; // default value for the ComboBox


Thanks,
A2H
My Blog

Bhupentiwari, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhupentiwari on: 3/4/2016 [Member] Starter | Points: 25

Up
0
Down
Hi A2H

if i use cmbLubOilSystemID.Value = "Here provide the LubOilSystemID which you want as selected"; // default value for the ComboBox

then it will display id in combox not text beacause it is not normal combox its DataGridViewComboBoxCell

so it will not work.




Thanks n Regards
Bhupendra Tiwari

Bhupentiwari, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response