ComboBox IsReadOnly + MouseEnter and MouseLeave

2 posts, 0 answers
  1. B
    B avatar
    74 posts
    Member since:
    Jul 2011

    Posted 27 May 2015 Link to this post


     I need a ComboBox where

    1. The user can't select items with the mouse
    2. The user can't select items with the keyboard
    3. The MouseEnter and MouseLeave events still fire

    I thought setting IsReadOnly to true would make the control readonly, but that doesnt seem to do anything? 

    So far the only thing that gets close is the code below, but that seems to still allow keyboard selection to slip through about 1 in 3 tries despite the flag.

    Is there a "real" way to do this? I mean one that is not so hacked and that works all the time?

    The way the control looks is not much of an issue (e.g. IsEnabled = false is fine), but I do need the MouseEnter and MouseLeave events and the user should not be able to change the value in any way.



    if (isReadOnly)
        c.MainComboBox.MaxDropDownHeight = 0;
        c.MainComboBox.CanKeyboardNavigationSelectItems = false;
        c.MainComboBox.MaxDropDownHeight = 300;
        c.MainComboBox.CanKeyboardNavigationSelectItems = true;
    c.MainComboBox.IsReadOnly = isReadOnly;

  2. Nasko
    Nasko avatar
    555 posts

    Posted 29 May 2015 Link to this post

    Hi Demir,

    In order to prevent the user from selection RadComboBoxItems you could disable them. That could easily be achieve using ItemContainerStyle and inside a Setter set the IsEnabled property to "False" - thus the items would be disable and the user won't be able to select it with the mouse or the keyboard. At the same time the MouseLeave and MouseEnter events should fire as expected. Please, check the following article from our help documentation that provides a detailed information how to achieve the described above approach:

    Hopes this helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top