Ticket Q370411
Visible to All Users

GridControl - How to change the BestFit algorithm

created 12 years ago

Absolutely interesting. Well, now we are talking. I add extra 20 pixels for graphics in the beginning of certain columns; when in CustomDrawCell() event. column.BestFit() don't know about this extra space; thereby cutting the last 20 pixels of the end of text. If I could somehow tell the BestFit() method that I want it to prefix with 20 pixels; the BestFit() algorithm could use this info to correctly fit the cell width. The interface could be something as simple as column.BestFit(int WidthExtention = 0).

Answers

created 12 years ago

As a quick fix, you can simply loop through all of the columns in your View, get the BestFit size, add 20 pixels, and set the ColumnWidth property. For instace:

C#
private void MyBestFit(int ColumnPadding) { int BestColumnWidth = 0; foreach (GridColumn column in gridView1.VisibleColumns) { BestColumnWidth = gridView1.CalcColumnBestWidth(column); column.Width = (BestColumnWidth + ColumnPadding); } }

And then, simply call that method instead of the GridView's BestFitColumns method.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.