Having trouble auto sizing a column. Probably doing it wrong. --------------------------------------------
grid1.Columns[0].AutoSizeMode = AutoSizeMode.EnableAutoSize;
... then I populate the rows followed by ...
grid1.Columns.AutoSizeColumn(0);
Thanks!
Do you receive an error or a wrong result?
Can you try to explain the problem with a more extended description?
Davide
Davide,
Consider this example:
grid1.BorderStyle = BorderStyle.FixedSingle; grid1.ColumnsCount = 2; grid1.FixedColumns = 1; grid1.FixedRows = 1;
grid1.Rows.Insert(0); grid1[0, 0] = new SourceGrid.Cells.Cell("colHeader1"); grid1[0, 1] = new SourceGrid.Cells.Cell("colHeader2");
grid1.Rows.Insert(1); grid1[1, 0] = new SourceGrid.Cells.Cell("rowHeader1"); grid1[1, 1] = new SourceGrid.Cells.Cell("cellValue1");
grid1.Rows.Insert(1); grid1[2, 0] = new SourceGrid.Cells.Cell("rowHeader2"); grid1[2, 1] = new SourceGrid.Cells.Cell("cellValue2");
grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; grid1.Columns.AutoSizeColumn(0);
The results seems to actually make column 0 smaller instead of increasing it to fit the text.
You are right. There is a bug in the AutoSize method. I open a bug report and I will try to fix it soon.
Thanks
I think to have solved this bug in the new version that I have just released (4.0.0.2).
Log in to post a comment.
Having trouble auto sizing a column. Probably doing it wrong.
--------------------------------------------
grid1.Columns[0].AutoSizeMode = AutoSizeMode.EnableAutoSize;
... then I populate the rows followed by ...
grid1.Columns.AutoSizeColumn(0);
Thanks!
Do you receive an error or a wrong result?
Can you try to explain the problem with a more extended description?
Davide
Davide,
Consider this example:
grid1.BorderStyle = BorderStyle.FixedSingle;
grid1.ColumnsCount = 2;
grid1.FixedColumns = 1;
grid1.FixedRows = 1;
grid1.Rows.Insert(0);
grid1[0, 0] = new SourceGrid.Cells.Cell("colHeader1");
grid1[0, 1] = new SourceGrid.Cells.Cell("colHeader2");
grid1.Rows.Insert(1);
grid1[1, 0] = new SourceGrid.Cells.Cell("rowHeader1");
grid1[1, 1] = new SourceGrid.Cells.Cell("cellValue1");
grid1.Rows.Insert(1);
grid1[2, 0] = new SourceGrid.Cells.Cell("rowHeader2");
grid1[2, 1] = new SourceGrid.Cells.Cell("cellValue2");
grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize;
grid1.Columns.AutoSizeColumn(0);
The results seems to actually make column 0 smaller instead of increasing it to fit the text.
You are right. There is a bug in the AutoSize method. I open a bug report and I will try to fix it soon.
Thanks
Davide
I think to have solved this bug in the new version that I have just released (4.0.0.2).