M
Mamba
Hi all
Working on a winform app that will read a table structure and display the
column names within a datagrid. I want to adjust the column widths to fit
the control size where possible.
Instead of attacking each column separately, I opted for a "higher level"
fix for column widths, and just tried to set the PreferredColumnWidth based
on the number of columns and a guesstimate of the available pixels in the
control.
ie.
dataGrid2.PreferredColumnWidth = numCols/availPixels;
dataGrid2.Refresh()
It seems that it works once or twice when I select tables with decreasing
numbers of columns - I see the column width expand to fill in the available
space. However, when I select tables with increasing numbers of columns,
the column width seems to "stick" at a higher value and screw up the
display, even though I can see the PreferredColumnWidth property assignment
happening correctly in the debugger.
Anybody know A) why this is happening?, B) how to fix it, or C) a better way
to handle this?
Thanks
Gary
Working on a winform app that will read a table structure and display the
column names within a datagrid. I want to adjust the column widths to fit
the control size where possible.
Instead of attacking each column separately, I opted for a "higher level"
fix for column widths, and just tried to set the PreferredColumnWidth based
on the number of columns and a guesstimate of the available pixels in the
control.
ie.
dataGrid2.PreferredColumnWidth = numCols/availPixels;
dataGrid2.Refresh()
It seems that it works once or twice when I select tables with decreasing
numbers of columns - I see the column width expand to fill in the available
space. However, when I select tables with increasing numbers of columns,
the column width seems to "stick" at a higher value and screw up the
display, even though I can see the PreferredColumnWidth property assignment
happening correctly in the debugger.
Anybody know A) why this is happening?, B) how to fix it, or C) a better way
to handle this?
Thanks
Gary