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?
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.
Hello,
I'm afraid I don't quite understand what you're trying to do. Could you please describe your question in more detail? What do you mean by saying " 2, 3 or 4 rows are visible"? Do you wish to display only one row in a GridView? If so, in which way should the control's height change when scrolling rows? How about other rows? In which way they should be displayed? I have also attached a sample project which demonstrates how to calculate the GridControl's height based upon the necessary rows height. Please review it and inform me whether this approach suits your needs.
I'm awaiting your response.
Thanks,
Stan.
Example: I have a gridControl with 3 rows. I want to resize the GridControl so only those 3 rows are visible. I don't want any white space underneath the last row. And if I display 2 rows I want to resize the gridControl so only those 2 rows are visible, again no white space underneath the last row.
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.
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.
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.