Infragistics Home

Infragistics Forums

Infragistics community online discussions.
Welcome to Infragistics Forums Sign in | FAQ
in Search

Capture mouse click on icon

Last post 07-29-2008 11:25 by rodgersgb. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-25-2008 1:31

    Capture mouse click on icon

    I have an UltraListView (View = List) with icons and check boxes enabled. How do I capture mouse clicks on the icon? 

    • Post Points: 20
  • 07-25-2008 10:15 In reply to

    Re: Capture mouse click on icon

    void listView_MouseClick(object sender, MouseEventArgs e)
    {
        UltraListView listView = sender as UltraListView;
        UltraListViewUIElement controlElement = listView.UIElement;
        ImageUIElement imageElement = controlElement.ElementFromPoint( e.Location ) as ImageUIElement;

        if ( imageElement != null )
        {
            UltraListViewItem item = imageElement.GetContext( typeof(UltraListViewItem) ) as UltraListViewItem;

            if ( item != null )
                this.OnImageClick( item );
        }
    }

    private void OnImageClick( UltraListViewItem item )
    {
    }

    • Post Points: 20
  • 07-26-2008 22:31 In reply to

    Re: Capture mouse click on icon

    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.

    • Post Points: 20
  • 07-29-2008 9:46 In reply to

    Re: Capture mouse click on icon

    Answer

    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();
                }
            }
        }
    }

    • Post Points: 20
  • 07-29-2008 11:25 In reply to

    Re: Capture mouse click on icon

    Thanks Brian, that worked like a champ. I think I'm getting a handle on these creation filters.

     cheers

    • Post Points: 5
Page 1 of 1 (5 items)
Powered by Community Server (Commercial Edition), by Telligent Systems