How to put several ComboBox in a DataGridView

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ang

    How to put several ComboBox in a DataGridView

    HI,

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


    // blockList, cSubjectGroupLi st, subjectGroupLis t are DataTable

    foreach (DataRow blockRow in blockList.Rows)
    {
    DataGridViewCom boBoxColumn column = new DataGridViewCom boBoxColumn();
    column.DataSour ce = cSubjectGroupLi st;
    column.ValueMem ber =
    subjectGroupLis t.Columns["Subject_Gr oup"].ToString();
    column.DisplayM ember =
    subjectGroupLis t.Columns["Subject_Gr oup"].ToString();
    column.Name = blockRow["Block"].ToString();

    dataTable1.Colu mns.Add(blockRo w["Block"].ToString());

    column.DataProp ertyName = blockRow["Block"].ToString();
    dataGridView1.C olumns.Add(colu mn);
    }

    dataGridView1.D ataSource = dataTable1

    *** Sent via Developersdex http://www.developersdex.com ***
  • jkricka

    #2
    Re: How to put several ComboBox in a DataGridView

    On Tue, 29 Apr 2008 02:36:26 -0700, Ang wrote:
    HI,
    >
    I want to put several DataGridViewCom boBox (which map their own
    datatable) into a DataGridView. Different Rows of DataGridView will load
    their own DataGridViewCom boBox.
    is it possible to do so?
    >
    >
    // blockList, cSubjectGroupLi st, subjectGroupLis t are DataTable
    >
    foreach (DataRow blockRow in blockList.Rows)
    {
    DataGridViewCom boBoxColumn column = new DataGridViewCom boBoxColumn();
    column.DataSour ce = cSubjectGroupLi st;
    column.ValueMem ber =
    subjectGroupLis t.Columns["Subject_Gr oup"].ToString();
    column.DisplayM ember =
    subjectGroupLis t.Columns["Subject_Gr oup"].ToString();
    column.Name = blockRow["Block"].ToString();
    >
    dataTable1.Colu mns.Add(blockRo w["Block"].ToString());
    >
    column.DataProp ertyName = blockRow["Block"].ToString();
    dataGridView1.C olumns.Add(colu mn);
    }
    >
    dataGridView1.D ataSource = 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 :)

    Comment

    Working...