Binding data into radMulti Column ComboBox

10 posts, 0 answers
  1. pogy
    pogy avatar
    17 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 Link to this post

    I have list of `NetworkAdapter` object that represent my machine `Network adapter`:

            List<NetworkAdapter> adaptersList
        
            public class NetworkAdapter
            {
                public string Name { get; set; }
                public string ID { get; set; }
                public string Description { get; set; }
                public string IPAddress { get; set; }
                private string gatewayIpAddress;
                public string Speed { get; set; }
                public string NetworkInterfaceType { get; set; }
                public string MacAddress { get; set; }
           }

    And i want to bonding every obkect from the list with all its properties into my `radMulti Column ComboBox`

    This is what i have try:

        radMultiColumnComboBoxTest.DataSource = adaptersList;

    This is the result:



    Any idea how to fix it in order to see every object from the list with all its properties instead of columns ?
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 Mar 2014 Link to this post

    Hi Pogy,

    Thank you for writing.

    Please refer to the following article which explains how to populate RadGridView (RadMultiColumnComboBox respectively) with data from an object and keep them in sync: http://www.telerik.com/help/winforms/gridview-populating-with-data-reflecting-custom-object-changes-in-rgv.html.

    I hope this helps.

    Regards,
    Stefan
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. pogy
    pogy avatar
    17 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 in reply to Stefan Link to this post

    But this exactly what i am did.

    instead of List<Student> collectionOfStudents = new List<Student>(); i have my List: List<NetworkAdapter> adaptersList

    and instead of this.radGridView1.DataSource = collectionOfStudents; --> radMultiColumnComboBoxTest.DataSource = adaptersList;
  5. pogy
    pogy avatar
    17 posts
    Member since:
    Mar 2014

    Posted 28 Mar 2014 Link to this post

    I want to show all my object properties without any columns like this example:

    http://www.telerik.com/sfimages/default-source/productsimages/winforms/productitemfeatures/radcomboboxwin_double_click1.png?sfvrsn=0
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 31 Mar 2014 Link to this post

    Hi Pogy,

    I am not sure why you are not able to bind your control as in the example provided. I made a small test and everything seems to be working on my end:
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
     
        radMultiColumnComboBox1 = new RadMultiColumnComboBox();
        radMultiColumnComboBox1.Width = 300;
        radMultiColumnComboBox1.Parent = this;
     
        List<NetworkAdapter> adaptersList = new List<NetworkAdapter>();
     
        for (int i = 0; i < 10; i++)
        {
            NetworkAdapter adapter = new NetworkAdapter();
            adapter.Name = "name " + i;
            adapter.ID = i.ToString();
            adapter.Description = "Some desc" + i;
     
            adaptersList.Add(adapter);
        }
     
        radMultiColumnComboBox1.DataSource = adaptersList;
    }

    To show all your object properties, without columns in separate controls, you can use RadDropDownList control. You should add as many control as you need and you should bind each one of them to the desired object property. Here is the control's documentation: http://www.telerik.com/help/winforms/dropdown-and-listcontrol-dropdownlist-overview.html. As this control internally hosts RadListControl, the latter documentation is also valid for RadDropDownList. Also, here is the place to read for the control's binding: http://www.telerik.com/help/winforms/dropdown-and-listcontrol-listcontrol-databinding.html

    I hope this helps.

    Regards,
    Stefan
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  7. pogy
    pogy avatar
    17 posts
    Member since:
    Mar 2014

    Posted 31 Mar 2014 in reply to Stefan Link to this post

    Thanks a lot for your response..

    currently your code behave same as mind and all i want to do is to remove the column but using MultiColumnComboBox
    is it possible ?
  8. pogy
    pogy avatar
    17 posts
    Member since:
    Mar 2014

    Posted 31 Mar 2014 in reply to pogy Link to this post

    I also try to concatenate strings to show all my Network Adapter properties:

            private void test()
            {
                string str = "";
                for (int i = 0; i < adaptersList.Count; i++)
                {
                    str += adaptersList[i].Name + Environment.NewLine +
                        adaptersList[i].ID + Environment.NewLine +
                        adaptersList[i].Description + Environment.NewLine;
                }

                radMultiColumnComboBox1.DataSource = str;
            }

    But the result was that the MultiComboBox was empty (no data to display) and the combobox header was Telerik.WinControls.Ui.GridViewDataRowInfo





  9. pogy
    pogy avatar
    17 posts
    Member since:
    Mar 2014

    Posted 31 Mar 2014 in reply to pogy Link to this post

    Can you show me please hot to define simple RadMultiColumnComboBox like this:

    http://www.telerik.com/sfimages/default-source/productsimages/winforms/productitemfeatures/radcomboboxwin_double_click1.png?sfvrsn=0

    All i want to do is to show few strings lines inside each index (no pic no nothing else)
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 01 Apr 2014 Link to this post

    Hello Pogy,

    If I understand correctly, you would like in оnе and the same item, to display the information from all properties of your object. Until now I thought you want to present your data in a grid like format, as you constantly mention RadMultiColumnComboBox, which internally contains a grid.

    To achieve the scenario with the custom item, holding information about your object, you will need to use RadDropDownList with custom visual item. The following article describes how such can be created: http://www.telerik.com/help/winforms/dropdown-and-listcontrol-listcontrol-visual-data-representation.html.

    Alternatively, if you just want to concatenate the property settings and display them below, you can use the 
    DescriptionTextListDataItem. Here is a small example of this:
    protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
     
                RadDropDownList ddl = new RadDropDownList();
                ddl.Parent = this;
                ddl.AutoSizeItems = true;
     
                List<NetworkAdapter> adaptersList = new List<NetworkAdapter>();
     
                for (int i = 0; i < 10; i++)
                {
                    NetworkAdapter adapter = new NetworkAdapter();
                    adapter.Name = "name " + i;
                    adapter.ID = i.ToString();
                    adapter.Description = "Some desc" + i;
     
                    adaptersList.Add(adapter);
                }
     
                for (int i = 0; i < adaptersList.Count; i++)
                {
                    string str = adaptersList[i].Name + Environment.NewLine +
                        adaptersList[i].ID + Environment.NewLine +
                        adaptersList[i].Description + Environment.NewLine;
     
                    DescriptionTextListDataItem descItem = new DescriptionTextListDataItem();
                    descItem.Text = "Main text";
                    descItem.DescriptionText = str;
                    ddl.Items.Add(descItem);
                }
            }

    Let me know how this works for you.

    Regards,
    Stefan
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  11. pogy
    pogy avatar
    17 posts
    Member since:
    Mar 2014

    Posted 01 Apr 2014 in reply to Stefan Link to this post

    Yes !
    that's exactly what i want to achieve, thanks a lot for your help !
Back to Top
UI for WinForms is Visual Studio 2017 Ready