Welcome to the Xceed Community | Help
Community Search  

GridControl sizing

Sort Posts: Previous Next
  •  11-21-2008, 6:24 AM Post no. 17081

    GridControl sizing

    Hi all,

    I'm building an app where I have four GridControls in a resizable form.  These GridControls hold a variable amount of rows, though never more than a couple dozens or so, and they are arranged in a column.

    I want the vertical size of the GridControls to always be the right size to display all of the rows they contain (plus the insertion row), and no more. Ideally, the GridControls should never display the vertical scrollbar. If the user adds rows, the relevant GridControl should become taller. If the form is too small to contain all the rows of all the GridControls, then a vertical scrollbar should appear on the form itself.

    I'm running into problems implementing this because it seems that the GridControl is basically designed to have a fixed size. I can't find a way to tell it to resize itself dynamically.

    I guess I could take the row count, multiply it by something, add something else, and do the resizing myself whenever the user adds or removes a row, but that sounds like a really inelegant solution - and how do I figure out row and header height with certainty, what with styles and spacing and stuff?

    Is there any way to just make the GridControl autosize to match its contents?

  •  11-21-2008, 2:21 PM Post no. 17094 in reply to 17081

    Re: GridControl sizing

    There is no feature on the GridControl to do this.  You will have to do it yourself.  Though  you may find this inelegant, if we were to implement such a feature, it would be implemented this way, that is, get the height of all elements being displayed in the grid, and adjust the grid height to the result.

    Basically, you need to get the height of each DataRow if you allow you use to modify the height of rows, or if you set the height to fit all content, else you could use the DataRowTemplate Height property.  You will also need to get the height of each row in the GridControl FixedHeaderRows/FixedFootersRows and HeaderRows/Footers.  Moreover, if you allow groups or detail grids, then you will have to take into account all of these, and verify for each instance of a group or detail if they are expanded or collapsed, and add the spacing for the DetailGrids.


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.