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
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;
thanks for your answer!
till now i defined basic size for the control and in the row insert/ row delete event of the grid i added to the basic size of the parent control the row inseted size (when insert) and removed the row deleted size (when deleted)
i wrote here because i really want to find more elegant solution.
isnt there a way to use the auto size somehow for what i need? becaue besically all i want is that the grid will define the parent control size and not the other way around...
Thanks, Michal
Hi MIchal,
No, there's no easy way to do this. The grid does not have any functionality to size itself to it's contents.
You should Submit a feature request to Infragistics