Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
UltraWinGrid resize
posted

Hi,

i have a user cntrol that contains table layout. one of the table layout columns contains ultra expandable group box. the ultra expandable group box contains another user control that has only UltraWinGrid in it.

right now every component it docked to the component above her (every component is docked to the component that includes her)

i want the UltraWinGrid size to fit the number of rows inside it, and the ultra group box size to fit the size of the ultraWinGrid inside it and so on.

i just want my user control to change size automaticlly according to the number of rows in the grid.

how can i do that?

do i need to use the auto size property? how?

please show an example if possible

i cant find the way to do it.....

thanks, Michal

Parents
  • 17259
    Offline posted

    I don't know how to do it but I can give you two tips:

    1. A docked control Size property is being ignored. If you want to change its size, just change its parent size, So you should find a way to calculate the size needed for the grid, and set it as the size of the top most control, which is the table column.

    2. If you'll get no luck with this, You can give the user a simple way to expand any grid he wants if there are too many columns or rows by transfering the grid to another form when it is being double clicked.

    a. Handle the DoubleClick event.

    b. Check if the click was on the caption bar (if you like)

    UIElement uiElement = grid.DisplayLayout.UIElement.ElementFromPoint(grid.PointToClient(Cursor.Position));

     

    if (uiElement != null)

    {

    var context = uiElement.GetContext();

    if (context == grid)

    ChangeGridContainer();

    }

    c. In ChangeGridContainer(), cache the grid container (the usercontrol) somewhere, and open a new form and put the grid in it:

    PreviousContainer = grid.Parent;

    var form = new Form();

    form.Owner = grid.FindForm();

    form.Controls.Add(grid);

    form.WindowState = FormWindowState.Maximized;

    form.FormClosing += new FormClosingEventHandler(form_FormClosing);

    form.Show();

    d. In the form_FormClosing event handler, return the grid to its container:

    PreviousContainer.Controls.Add(grid);

    PreviousContainer = null;

Reply Children