How to put several ComboBox in a DataGridView

A

Ang

HI,

I want to put several DataGridViewComboBox (which map their own
datatable) into a DataGridView. Different Rows of DataGridView will load
their own DataGridViewComboBox.
is it possible to do so?


// blockList, cSubjectGroupList, subjectGroupList are DataTable

foreach (DataRow blockRow in blockList.Rows)
{
DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn();
column.DataSource = cSubjectGroupList;
column.ValueMember =
subjectGroupList.Columns["Subject_Group"].ToString();
column.DisplayMember =
subjectGroupList.Columns["Subject_Group"].ToString();
column.Name = blockRow["Block"].ToString();

dataTable1.Columns.Add(blockRow["Block"].ToString());

column.DataPropertyName = blockRow["Block"].ToString();
dataGridView1.Columns.Add(column);
}

dataGridView1.DataSource = dataTable1
 
J

jkricka

HI,

I want to put several DataGridViewComboBox (which map their own
datatable) into a DataGridView. Different Rows of DataGridView will load
their own DataGridViewComboBox.
is it possible to do so?


// blockList, cSubjectGroupList, subjectGroupList are DataTable

foreach (DataRow blockRow in blockList.Rows)
{
DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn();
column.DataSource = cSubjectGroupList;
column.ValueMember =
subjectGroupList.Columns["Subject_Group"].ToString();
column.DisplayMember =
subjectGroupList.Columns["Subject_Group"].ToString();
column.Name = blockRow["Block"].ToString();

dataTable1.Columns.Add(blockRow["Block"].ToString());

column.DataPropertyName = blockRow["Block"].ToString();
dataGridView1.Columns.Add(column);
}

dataGridView1.DataSource = dataTable1

I think not. I had same problem which we solved by positioning regular
combo box on datagridview cell dynamically :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top