how to Best Fit(All Columns) in a GridControl
-
05-07-2021 - |
문제
How to best fit all the columns in a grid control when form is loaded. I do have a button as shown in the following picture to do that when i right click the header of the grid control, but as opposed to this I want this event to be fired automatically when the form is loaded. I don't want to do this by right clicking the header of the grid control and than clicking the Best Fit(all columns) button to best fit all the columns.
해결책
This is how I do it.
if (view is GridView)
{
// auto best fit...
(view as GridView).BestFitMaxRowCount = 5000; // just to avoid to many compares
(view as GridView).BestFitColumns();
foreach (GridColumn item in (view as GridView).Columns) // reduce the width of very wide columns
{
item.Width = (item.Width > 1000) ? 1000 : item.Width;
}
}
다른 팁
following Code BestFit All the Columns Provided that FixedWidth of All the Columns is set to False
GridView.BestFitColumns();
제휴하지 않습니다 StackOverflow