I have a wingrid and the approx 230 columns and these columns are divided into 5 different groups
The problem is one of the group has 100 columns and the Group Header Caption is visible only in the middle,
Was wondering if there was a way i can position the group header caption w.r.t the coll scroll region position so that the user can notice which group the column below belongs to.
Any Help is appreciated
Thanks
Kartik
Hi Kartik,
There's no property setting to do this, but you could do it with a CreationFilter. Here's a sample CreationFilter that seems to work okay:
public class GroupHeaderCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { // If this is not a HeaderUIElement, do nothing. HeaderUIElement headerElement = parent as HeaderUIElement; if (headerElement == null) return; // If the header has a column or has no group, then it's not a group header, // so just bail out. if (headerElement.Header.Column != null || headerElement.Header.Group == null) return; // Get the TextUIElement contained within the header. TextUIElement textElement = parent.GetDescendant(typeof(TextUIElement)) as TextUIElement; // If we failed to find a TextUIElement, bail out. if (textElement == null) return; // Make the text element fill the ClipRect of the parent element, rather than the // entire rect. textElement.Rect = parent.ClipRect; // Invalidate the area so that it repaints. parent.Control.Invalidate(parent.ClipRect); } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // Do nothing return false; } #endregion }
You just create an instance of this class and assign it to the CreationFilter property of the grid. You only have to do this once, so the Form_Load it a good place for it:
this.ultraGrid1.CreationFilter = new GroupHeaderCreationFilter();
Firstly thank for the code and explaining how it works, and also let me say you guys do a great job up there at infragistics.
Now comming to the problem, the code works like a charm but the problem is we already have a creation filter on the grid which displays chemical structures on the grid and as far as i know there can be only one creation filter per grid unless you tell me no. Is there any other way apart from creation filter?
You can only use one CreationFilter on the grid. So you will have to merge this code into your existing CreationFilter class. Since this code does nothing in the BeforeCreateChildElements, you can just add the code from the AfterCreateChildElements into your existing method.
Another option would be to create a new CreationFilter class that contains a collection of CreationFilters and calls into the methods on each one in turn.
That is right, that is what i eventually did but the overhead is a lot, because the way i guess the creation filter works "internally" is through the colscrollregion event, each time the user scrolls the columns the class gets called and the reason these chemical structures render through calling a third party dll the number of calls to the .dll is a lot. i'd see if the performance is better through WPF grid.
I'll post what i learn.
Using a DrawFilter or a CreationFilter is a like handling the Paint event of a control. You have to make sure your code is very efficient because it will get called quite a lot. So I can see how this might be a problem if your drawing code is complex.