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?
Hi,
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.
Thank you.
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.