Home Forums WinForms controls Xceed Grid for WinForms GridControl sizing

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16657 |

    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?

    Imported from legacy forums. Posted by Filippo (had 637 views)

    User (Old forums)
    Member
    Post count: 23064

    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.

    Imported from legacy forums. Posted by André (had 835 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.