One of the requirements I have for the Datagrid is to allow the user to resize all the columns to there liking and beable to save off the widths and reapply them when to go back to the page at a later time.
I figure I can just look through all the Fields in the FieldLayout, and read off the width, but is there an easier way to extract that information and put it back ?
Thanks
DK
In the current version, there is no built in mechanism for saving the user customizations but you should submit a suggestion for this feature: http://devcenter.infragistics.com/Protected/RequestFeature.aspx
In the interim, you would have to iterate the Fields in the FieldLayout and look at the (Cell|Label)WidthResolved values and use those to initialize the (Cell|Label)Width when you load them back in. Note, in the current builds available, the resolved properties will not return the resized value but this issue has been reported internally and will be addressed in the next hotfix. You may want to submit a report to the support group and reference issue BR25223 so you can be notified when the hotfix is available.
Hey Andrew,
What you posted make sense, pretty simple for me to apply the widths back in during a FieldLayoutInit event.
However, I would like to capture when the user changes the column widths, and update my local list of column widths.
I tried to use the SizeChangedEvent on the LabelPresenter and HeaderPresenter and a few other classes. But all these give me a SizeChanged event no matter how the column got resized.
Is there an event tied specficly to when the user resizes a column?
I want to capture it and go ahead and update my stored column widths.
Any recommendation on how I could do this ?
Unfortunately there isn't an event specific to resizing right now so I submitted a suggestion for it (as well as one for including save/load of user customizations). The SizeChanged event is defined on FrameworkElement and has to do with when the render size has changed so it would fire even when the element is just being positioned. I haven't tested this out but perhaps for now you could assume that a SizeChanged that occurs while the Mouse.LeftButton is Pressed means that a size change via a user interaction has changed (perhaps also limited to when the Mouse.Captured is non-null and is the DP or one of its descendants to ignore the case where a column is resized/positioned when the form, etc. is resized).
I will take a look at what you suggested with the mouse and go from there.
Thanks For the quick response.
If you get a chance to test out what your suggesting, could you post up some example code?
Hi,
one of the soulution for catching user width change may be using SizeChange method and checking some of the fields from SizeChangedEventArgs:
private void labelPresenter_SizeChanged(object sender, SizeChangedEventArgs e) { if (e.WidthChanged && e.PreviousSize.Width != 0) { LabelPresenter lb = (e.OriginalSource as LabelPresenter); double colWidth = lb.Field.LabelWidthResolved; } }
Thanks!
I also would like to save and re-apply column width when user changes it. Did any body found a proper solution to this? Any sample/suggestion would help.
Thanks,
ND