I have an UltraListView (View = List) with icons and check boxes enabled. How do I capture mouse clicks on the icon?
The control exposes two events, MouseEnterElement and MouseLeaveElement, that fire when the cursor enters/exits the bounds of a UIElement. In this case you want to handle elements of type UltraListViewItemUIElement, and after upcasting to that type, set the UltraListViewItemUIElement.Item.Appearance.Image.
Hi,
I have a simular problem:
I want to change the image of the Icon on the UltraListView when the mouse enters the ListItem.
And ofcourse set the original image back when the cursor leaves the ListItem.
I get the images from the db, so it must be done at runtime.
Thanks Brian, that worked like a champ. I think I'm getting a handle on these creation filters.
cheers
Note that the Infragistics.Win.Appearance object exposes properties like ForeColorDisabled and BackColorDisabled so that you can customize the way disabled items look. There is, however, no property through which you can assign an image that is displayed only when the item is disabled.
The following code sample demonstrates how to make the images displayed by UltraListViewItems always look enabled, regardless of the associated item's enambed state:
this.listView.CreationFilter = new DisabledImageCreationFilter();
private class DisabledImageCreationFilter : IUIElementCreationFilter{ #region IUIElementCreationFilter Members
void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { if ( parent is UltraListViewItemEditorAreaUIElement ) { ImageUIElement imageElement = parent.GetDescendant( typeof(ImageUIElement) ) as ImageUIElement; if ( imageElement != null ) { UIElementsCollection childElements = imageElement.Parent.ChildElements; AlwaysEnabledImageUIElement newElement = new AlwaysEnabledImageUIElement( parent, imageElement.Image ); newElement.Rect = imageElement.Rect;
childElements.Remove( imageElement ); childElements.Add( newElement ); } } }
bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { return false; }
#endregion
private class AlwaysEnabledImageUIElement : ImageUIElement { public AlwaysEnabledImageUIElement( UIElement parent, Image image ) : base( parent, image ){}
public override bool Enabled { get { return true; } set { throw new NotSupportedException(); } } }}
Thanks, that worked.
Another question, is there any way to control the disabled appearance of an ultralistviewitem? I'm using the appstylist and it does not provide a disabled option (neither does any of the appearance properties). The big thing is, since i'm toggling between icons when clicked on, I don't want the icon to change to a disabled state (gray color) when the listviewitem is disabled. I want the item to be disabled (and the icon for that matter) but I don't want the color of the icon to change.