Setting RadDropDownList to NoSelection in code

8 posts, 0 answers
  1. Baldwin
    Baldwin avatar
    10 posts
    Member since:
    Jul 2010

    Posted 30 Aug 2010 Link to this post

    Hello everybody.

    I have a problem with rad drop downlist.
    My drop down list is unbound and populated during runtime, every item having text and value.
    A valid value to be displayed should be 'no selection' => SelectedValue = null
    The selected item should change after the selected node in a tree view is changed

    When I first select item which have null as value for the drop down list, everything's ok.
    But after an entry from the DrowDownList was selected and the try to change the SelectedValue to null, I have the problem, that even though the SelectedValue seems to be null, the text of the last selected item is still displayed.

    I tried setting the value to NULL by using:
    • SelectedValue = null;
    • SelectedIndex = -1;
    • SelectedItem = null;

    All produced the same result: The SelectedValue is null when I check, but there is still text displayed.
    So, my question is: how can I reset the DropDownList to a state where no item is selected by code.

    Thanks for any help

  2. NORIS
    NORIS avatar
    29 posts
    Member since:
    Jun 2009

    Posted 30 Aug 2010 Link to this post

    I experienced a similar problem.  I was able to resolve it by closing the the DropDown first and resetting the SelectedIndex and Text.
    Hope this helps.

    RadDropDownList1.CloseDropDown() 'get exception error or empty items in list if DropDown is open
    RadDropDownList1.SelectedIndex = -1 'keeps selected, even when no longer in list
    RadDropDownList1.Text = "" 'keeps text even when nothing in list
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Baldwin
    Baldwin avatar
    10 posts
    Member since:
    Jul 2010

    Posted 31 Aug 2010 Link to this post

    Thanks NORIS.

    The workaround helps, though in my tests, setting the Text-Property to String.Empty was sufficient. CloseDropDown() was not required.

    Still, I would like to know if there's an official way?

    Thanks again
  5. NORIS
    NORIS avatar
    29 posts
    Member since:
    Jun 2009

    Posted 31 Aug 2010 Link to this post

    I was told this is fixed in the lastest IB.
  6. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 02 Sep 2010 Link to this post

    Hello,

    Thank you for contacting us.

    We are aware of the issue with the deletion of items and RadDropDownList should update itself when selected item is null. This has been fixed in the latest internal build released on Aug 25. You can download this build from Your Account >> Downloads >> RadControls for WinForms >> Latest Internal Builds. The version of the build is v2010.2.10.825.

    Do not hesitate to contact us if you have additional questions.

    Best wishes,
    Peter
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  7. Baldwin
    Baldwin avatar
    10 posts
    Member since:
    Jul 2010

    Posted 06 Sep 2010 Link to this post

    Thanks.

    I will try out the internal build when I find time.
    Meanwhile, I have another partly related question about a problem with a bound drop down list:

    In this case, I have a bound drop down list which is in DropDown-Mode, thus allowing manual input.
    Now, an item is selected (SelectedValue is e.g. 1) and after that text is entered in the input field by the user.
    If the entered string is confirmed with Enter-Key, SelectedValue changes to Null (which was what I expected), but if the user leaves the input field without hitting Enter key, the SelectedValue stays at 1. I would like that the SelectedValue property also changes to null in that case.

    I considered using the TextChanged event but the event does not seem to fire for some reason.

    Is there a solution to this?
  8. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 08 Sep 2010 Link to this post

    Hi,

    Thanks for the provided details.

    You can subscrube for TextBox's TextChanged event:
     
    this.radDropDownList1.DropDownListElement.TextBox.TextChanged += new EventHandler(TextBox_TextChanged);
     
    We will include a fix for Control's TextChanged event in one of our next releases.
     
    Don't hesitate to contact us if you have other questions.

    Regards,
    Peter
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  9. Baldwin
    Baldwin avatar
    10 posts
    Member since:
    Jul 2010

    Posted 09 Sep 2010 Link to this post

    Thanks for the advice.
    That was indeed something I'd not have thought of.
Back to Top
UI for WinForms is Visual Studio 2017 Ready