Link to home
Start Free TrialLog in
Avatar of wilfordrocks
wilfordrocks

asked on

Datagridview will not resize the height of the rows.

I would like to increase the height of the rows in the datagridview.
Neither RowTemplate.Height or Height seem to be working.
Thank you for your suggestion.



int icounter = candidateList.Count;
//the grid has two coluns
                dataGridView1.Columns.Add("Id", "Id");
                dataGridView1.Columns.Add("Data", "Data");
                foreach (string s in candidateList)
                {
                    // Create a row and add two textbox cell to each row
                    DataGridViewRow dataGridRow = new DataGridViewRow();
                    dataGridView1.Height += 120; //this does not work
                    dataGridView1.RowTemplate.Height += 120; //and this does not work
                    DataGridViewCell[] cells = new DataGridViewCell[2];
                    DataGridViewTextBoxCell txtId = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell txtData = new DataGridViewTextBoxCell();

                    txtId.Value = icounter.ToString();
                    icounter--;
                    txtData.Value = s;
                    dataGridRow.Cells.Add(txtId);
                    txtId.ReadOnly = true;
                    dataGridRow.Cells.Add(txtData);
                    dataGridView1.Rows.Add(dataGridRow);
ASKER CERTIFIED SOLUTION
Avatar of mokule
mokule
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or just newly added?

dataGridRow.Height +=30;
Avatar of wilfordrocks
wilfordrocks

ASKER

The property AutoSizeRowMode had to be set to NONE.  That was the problem.
Thanks