RadDropDownList Databinding

3 posts, 0 answers
  1. Zain
    Zain avatar
    3 posts
    Member since:
    Oct 2011

    Posted 02 Feb 2012 Link to this post

    I have a RadDropDownList that I have successfully bound to a List object by setting the DisplayMember and ValueMember of the RadDropDownList to the properties of my data list object, and by setting the DataSource of the RadDropDown to the list.
    The above takes care of populating the choices in RadDropDown.

    I want to know if its possible to also bind the SelectedValue to another property in my data class. And if changes in this Data property would reflect back in the SelectedValue of the RadDropDown with the implementation of the INotifyPropertyChanged event for the Data property.
  2. Zain
    Zain avatar
    3 posts
    Member since:
    Oct 2011

    Posted 02 Feb 2012 Link to this post

    Nevermind, I figured this out on my own.
    After setting the datasource of the dropdown to a list, I can add a Databinding to the dropdown, and bind the "SelectedValue" property of the dropdown to the data object property.

    List <ListElement> myList = new List <ListElement>() { 
                                                                                          new ListElement() { ListElementVal = 1, ListElementDisp = "One" }, 
                                                                                          new ListElement() { ListElementVal = 2, ListElementDisp = "Two" }
                                                                                        };

    myDropDown.ValueMember =

     

    "ListElementVal";

     

    myDropDown.DisplayMember =

     

    "ListElementDisp";

     

    myDropDown.DataSource =

     

    myList;
    myDropDown.DataBindings.Add("SelectedValue", dataObjInst, "dataObjProperty");

     

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 06 Feb 2012 Link to this post

    Hello Zain,

    I am happy that you managed to resolve this case.

    Do not hesitate to write back in case you need further help.

    Greetings,
    Peter
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top