Hello,
I have a few grids where I'd like to achieve the following:
Have the column widths automatically determined via grd.MasterGridViewTemplate.BestFitColumns() except when the sum of the column widths under this method is less than the width of the grid itself. In this case, set the grd.MasterGridViewTemplate.AutoSizeColumnsMode to be Fill.
I have tried to do this via the following code, but it doesn't seem to be accurate when summing the column widths, and thus I am still getting cases where the columns do not fill the grid...
grdDifferences.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None; |
grdDifferences.MasterGridViewTemplate.BestFitColumns(); |
int iTotalWidth = grdDifferences.Width; |
int iCountWidth = 0; |
foreach (GridViewColumn column in grdDifferences.Columns) |
{ |
iCountWidth += column.Width; |
} |
if (iCountWidth < iTotalWidth) |
{ |
grdDifferences.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; |
} |
Any help would be appreciated.
Thanks!
Jeremy