RadGridView ComboBox

2 posts, 0 answers
  1. Chris
    Chris avatar
    16 posts
    Member since:
    Aug 2012

    Posted 30 Nov 2019 Link to this post

    C#, Winforms

    I have an XML data source (Main) that I am binding to my gridview. I want one column to be a combobox. I'm using a separate XML file (Options) for the combobox options. 

    Questions:

    1) When I set the data source for the combobox to the Options dataset, the column is blank. I want it to be the value listed in the Main dataset. The result I seek is that when the grid loads, the values from the Main dataset are loaded. The user can then edit the combobox column by selecting from the drop down that is populated from the Options dataset. How can I achieve this?

    2) Obviously, I want to save these back edits back to the main dataset. How can I rebind the column to the Main dataset?

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3952 posts

    Posted 02 Dec 2019 Link to this post

    Hello, Chris,

    After the grid is populated with data (after setting RadGridView.DataSource) and its columns are automatically generated, you can remove a certain column and add a new one, e.g. GridViewComboBoxColumn. You need to apply another collection for DataSource of the column together with column's DisplayMember and ValueMember properties. Note that the ValueMember needs to correspond to the values that you have in the cell, e.g. if you have ID and Name column and you have stored the IDs in the grid cells, in order to display the correct value when loading the grid, make sure that you specify the column's FieldName to the respective field in the applied RadGridView.DataSource collection. Thus, the cells' values will be populated with the respective values in the grid. Then, if you edit a cell, the value will be updated to the underlying DataBoundItem respectively. 

    Additional information how to setup the GridViewComboBoxColumn is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/columns/column-types/gridviewcomboboxcolumn 

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

     

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top