Nithesh Narayanan
Nithesh Narayanan

Reputation: 11775

Selected value of DataGridViewComboBoxCell

I am using the following code to bind a combo box column in gridview

DataGridViewComboBoxCell dgBatch = (DataGridViewComboBoxCell)grvProduct.Rows[pRowIndex].Cells[pComboColName];
            DataTable dtBatch = new DataTable();
            dtBatch = iExportSalesOrder.SelectProductDetails(pack_detl_ID);
            dgBatch.DataSource = dtBatch;
            dgBatch.ValueMember = "qty";
            dgBatch.DisplayMember = "sBatch_No";

I want to set a particular item as selected in this combo box based on some value. How can i set a selectedvalue in DataGridViewComboBoxCell .?

Upvotes: 0

Views: 3839

Answers (2)

Marshal
Marshal

Reputation: 6671

dgBatch[Column.Name, Row.Name].Value = value;

Upvotes: 0

ShankarSangoli
ShankarSangoli

Reputation: 69915

Set dgBatch.Value = "selectedValue" it should work.

Upvotes: 1

Related Questions