Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all:

I have a DataGridView with three columns bound to a DataTable. The second column can be a DataGridViewComboBoxCell, DataGridViewTextBoxCell, DataGridViewCheckBoxCell, or a custom made Calendar Cell, depending on the question.

Most of the cells in the second column look ok, except for the Combo Box cell. The height of the row can change, but the ComboBox height doesn't.
No matter what the height of the row is, the Combo Box shows up the same size in the row and it doesn't take up the entire cell that way. 'Size' and 'PreferredSize' are Read Only, so I can't change them:

using (DataGridViewComboBoxCell cbc = new DataGridViewComboBoxCell())
{
    cbc.FlatStyle = FlatStyle.System;
    cbc.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox;
    foreach (Answer a in AllAnswers)
    {
        if ((a.aQKey == AllQuestions[iNextQuestionIndex].qKey) && (a.aKey == AllQuestions[iNextQuestionIndex].qAnswerKey))
            cbc.Items.Add(a.aText);
    }
    dataGridView1[1, dataGridView1.Rows.Count - 1] = cbc;
    dataGridView1[1, dataGridView1.Rows.Count - 1].Value = cbc.Items[0];
    dataGridView1[2, dataGridView1.Rows.Count - 1] = new DataGridViewButtonCell();
    dataGridView1[2, dataGridView1.Rows.Count - 1].Value = "Accept";
}


(I actually had pictures of what it looks like now, and what I wanted it to look like, but it seems I cannot post pictures here). :(

Anyway, is there anything I can do about this?

Thank you,
Robert
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900