471,356 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,356 software developers and data experts.

How to put several ComboBox in a DataGridView

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

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #1
1 1293
On Tue, 29 Apr 2008 02:36:26 -0700, Ang wrote:
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

*** Sent via Developersdex http://www.developersdex.com ***
I think not. I had same problem which we solved by positioning regular
combo box on datagridview cell dynamically :)
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by | last post: by
3 posts views Thread by Przemek M. Zawada | last post: by
reply views Thread by Dom | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.