Ticket CQ24983
Visible to All Users

GridControl row height (cell height)

created 18 years ago

I would like to resize the gridControl (set its height), so 2, 3 or 4 rows are visible, no less no more. The height of the cell is calculated automatically based on font settings. Also the windows theme makes cells smaller or larger. I noticed with fonts size 8.25 and windows classic theme the cell height is 15, but with windows xp theme it is 16. I used the CustomDrawCell to retrieve this information. Is it possible to calculate the height of the gridcontrol so it's exactly the right height for displaying 2, 3, or 4 rows?

Show previous comments (2)
Stan (DevExpress Support) 18 years ago

    Hi,
    Thank you for the additional explanation. In this instance you can use the approach demonstrated in the attached sample.
    I'm looking forward to hearing from you.
    Thanks,
    Stan.

    MT MT
    Maarten Terlingen 18 years ago

      The sample is great and works fine, but something strange happens when I try to use it. When de gridView is displayed and I hit the button, the code to resize the gridControl is executed and info.ViewRects.Rows.Height actually return the correct height. I have multiple views which are created at runtime (I attached a sample jpg). I create an instance of the view, add it to a panel and then Initialize the view using a public function. Within this initialize function I use the code you provided, but now the info.ViewRects.Rows.Height is always 0, instead of the actual height. When I create a button on the view and execute the code manually after it's been displayed the gridControl does resize to the correct height. Is there a way to work around it? I don't understand why the correct height isn't returned.

      Stan (DevExpress Support) 18 years ago

        Hello,
        The cause of the problem is that we are using the lazy initialization pattern in our controls. This means that all the control's internal structures are only calculated when the control is displayed. However, you can force the initialization by calling the GridView's ForceInitialize method before calculating the necessary height.
        Please try this solution and inform us of your results.
        Thanks,
        Stan.

        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.