RadDropDownList ReadOnly

10 posts, 2 answers
  1. IGOR
    IGOR avatar
    4 posts
    Member since:
    Oct 2010

    Posted 15 Nov 2010 Link to this post

    Hi,
    Is there ways to make RadDropDownList text as "ReadOnly" in Run Time mode?
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 15 Nov 2010 Link to this post

    Hello IGOR,

    Yes, just change the dropdownstyle to dropdownlist.
    this.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;

    hope that helps
    richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. IGOR
    IGOR avatar
    4 posts
    Member since:
    Oct 2010

    Posted 16 Nov 2010 Link to this post

    Thanks a lot Richard.
    It was so clear to understand. I was thinking about something tricky like "...ReadOnly=true" :-)
    I'm new with TELERIK.

    Thanks a lot again.

    Igor

  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Nov 2010 Link to this post

    Glad to be of help Igor. May I ask that you mark the reply as answer though so others can find the solution too.
    Best regards,
    Richard
  6. Aziz
    Aziz avatar
    2 posts
    Member since:
    Jun 2012

    Posted 08 Jul 2013 Link to this post

    no no, setting the drop down style to drop down list still enables the user to change the drop down by picking another one from the list.
    what i want to do is to block the user from changing the value, like .enabled = false but with enabled = false the text becomes grayed out and horribly unreadable.
  7. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Jul 2013 Link to this post

    Hi, 

    There are 2 easy ways to do this. 

    1: If you still want the user to be able to open the DropDownList to show the possible values, but not allow changes, then you can use the "SelectedIndexChanging" event like this: 

    Private Sub DropDownList_SelectedIndexChanging(sender As System.Object, e As Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs) Handles DropDownList.SelectedIndexChanging
        e.Cancel = True
    End Sub

    2: If you don't want the user to open the list, you can cancel the PopUpOpening event

    Private Sub DropDownListOpening(sender As Object, e As CancelEventArgs) Handles DropDownList.PopupOpening
        e.Cancel = True
    End Sub

    Hope this helps
    Richard
  8. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 11 Jul 2013 Link to this post

    Hello Aziz,

    The ReadOnly property is not common for all controls and only few controls are implementing it (RadTextBox, RadSpinEditor) - in case that you want to prevent RadDropDownList from interaction with user you should use Richard's solution.

    There is a feature request for such property, feel free to add your vote for it here: http://www.telerik.com/support/pits.aspx#/details/Issue=10738.

    I hope this helps.

    Regards,
    Peter
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  9. Aziz
    Aziz avatar
    2 posts
    Member since:
    Jun 2012

    Posted 11 Jul 2013 Link to this post

    Yes it helps, thank you.
    nevertheless, i cannot help but noticing how ComponentOne have a ".readonly" property for their drop down list. and using it takes much less code than the solution you suggest ;)
  10. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 16 Jul 2013 Link to this post

    Hi Aziz,

    Thank you for writing back.

    As I mentioned the ReadOnly property is not common for all controls (for example Microsoft ComboxBox does not implement this property). You can use the Enable property (which is common for all controls) in order to disable user interaction with this control.

    Should you have any other questions, do not hesitate to ask.

    Regards,
    Peter
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  11. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 Jul 2013 Link to this post

    Aziz, 

    In addition to Peter's comments, you could also have a look at my answer in this thread which shows how to make readonly editors for all sorts of RadControl. 

    Hope this helps you further
    Richard
Back to Top
UI for WinForms is Visual Studio 2017 Ready