Hello Team,
I am trying to add an image to RowSelectorHeaderAppearance but somehow I am unable to do so. Please guide.
void DropDownGrid_InitializeLayout(object sender, InitializeLayoutEventArgs e) { e.Layout.Override.RowSelectorHeaderStyle = Infragistics.Win.UltraWinGrid.RowSelectorHeaderStyle.SeparateElement; Image img = com.st.common.Properties.Resources.BlueFilter; e.Layout.Override.RowSelectorHeaderAppearance.Image = img; //e.Layout.Bands[0].Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.SeparateElement; //e.Layout.Bands[0].Override.RowSelectorHeaderAppearance.Image = img; }
void DropDownGrid_MouseDown(object sender, MouseEventArgs e) { Infragistics.Win.UltraWinGrid.UltraGrid grid = sender as Infragistics.Win.UltraWinGrid.UltraGrid; if (grid != null) { UIElement element = grid.DisplayLayout.UIElement.LastElementEntered; if (element != null) { UIElement rowSelectorHeaderElement = element.GetAncestor(typeof(RowSelectorHeaderUIElement)) as RowSelectorHeaderUIElement; if (rowSelectorHeaderElement != null) { PerformFilter(); } else return; } else return; } }
Hi,
The RowSelectorHeader element doesn't support an image by default. But you could display one using a CreationFilter.
The CreationFilter code looks something like this:
public class RowSelectorHeaderImageCreationFilter : IUIElementCreationFilter { private Image image; public RowSelectorHeaderImageCreationFilter(Image image) { this.image = image; } void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { if (parent is RowSelectorHeaderUIElement) { var imageElement = parent.GetDescendant(typeof(ImageUIElement)) as ImageUIElement; if (null == imageElement) imageElement = new ImageUIElement(parent, this.image); else imageElement.Image = image; imageElement.CenterImage = true; imageElement.Rect = parent.RectInsideBorders; parent.ChildElements.Add(imageElement); return true; } return false; } }
And you hook it up to the grid like so:
this.ultraGrid1.CreationFilter = new RowSelectorHeaderImageCreationFilter(img);