I would like to allow a user to click an ultraGrid at runtime and be able to see the selection handles (white dots) and re-size the control like we can in the visual designer. Is this possible?
If you want your users to be able to resize controls at run-time, then you could use the inbox Splitter control, the UltraSplitter, or the SplitPanel.
Thanks, I will try the idea of the splitter.
Hi,
I just wanted to know if you were able to solve your issue based on Mike's suggestions or you still need help? Just let me know.
Thank you.
Thanks for your follow-up.
I tried the splitter setting the grid in one panel with dock fill, and that worked to some extent, but I didn't like the UI experience. It didn't seem like a pattern that end-users would be used to. What I ended up doing: Set the grid's AutoFitStyle to None, then subscribed to AfterColPosChanged. This let the user resize the last column of the grid, then I accumulated the total width of each visible column in the grid and resized the grid object to match.
In the past, I have used other controls that had a "Selectable" property that would allow a mouse-click on the control to put selection handles on the control. (Just like what visual studio does for us) This works great for applications where you want to let the end-users do screen-layouts at runtime. IMO this would be a nice enhancement for the base class of the Infragistics controls.
I never was able to achieve selection handles on the grid. However, my need for the selection handles was only so that a user could select and change the width of a grid.
What I did instead, was re-size the entire grid after the last column in the grid was re-sized. To do this, I used AfterColPosChanged and then re-sized my grid and form accordingly. This would give the illusion that the user was able to grab the right edge of a grid and re-size it like they would if it was a selection handle on the grid. The user was really just changing the width of the last column-- i was then setting the width of the grid to match with code.This is not C# code, but maybe it will help you get the idea.
METHOD PRIVATE VOID ultraGrid1_AfterColPosChanged (sender AS System.Object, e AS AfterColPosChangedEventArgs):
IF e:PosChanged:ToString() EQ "Sized" THEN DO:
/* After a grid column has been re-sized, calculate the total width of ** all visible columns and then set the width of the grid to that total. ** Note: This grid is not set to auto-size the last column. */
DEFINE VARIABLE iWidth AS INTEGER NO-UNDO.
ASSIGN
visibleColumn = ultraGrid1:DisplayLayout:Bands:Item[0]:GetFirstVisibleCol(ultraGrid1:ActiveColScrollRegion,TRUE) iWidth = 0 .
/* pass the visible columns of the grid... */ REPEAT WHILE VALID-OBJECT(visibleColumn): /* accumulate the total width */ ASSIGN iWidth = iWidth + VisibleColumn:Width visibleColumn = visibleColumn:GetRelatedVisibleColumn(Infragistics.Win.UltraWinGrid.VisibleRelation:Next) .
END.
/* The height of my grid is 24-- I only show the user the heading row of the grid */ ultraGrid1:Size = NEW System.Drawing.Size(iWidth + 5,24).
/* size the form to hold the grid */ THIS-OBJECT:Size = NEW System.Drawing.Size((ultraGrid1:Location:X * 2) + ultraGrid1:Size:Width + 10,THIS-OBJECT:Size:Height ).
END METHOD.
Can you please post the sample code that achived the desired behavior?
Thanks for the suggestions and sample. I do not need any additional help.
I did post an enhancement request that suggests a "selectable" property on the controls that would allow for selection handles to appear on click.
I just wanted to know if you were able to solve your issue based on suggestions that we provided to you or you still need help? Just let me know.
Hello,
I was able to achieve something like that. The sample is not perfect and if you bind data to the UltraGrid and if you try to resize it you might cause a performance issues, but I just wanted to give you something that might help you to achieve your goal.
I hope this help.