Dummies guide to combo boxes

5 posts, 0 answers
  1. Daniel
    Daniel avatar
    5 posts
    Member since:
    Feb 2016

    Posted 28 Jun Link to this post

    Hi

    I am having big issues (lack of knowledge) with creating combo boxes on a gridview bound to a dataset, Can someone please point me in the right direction?

    My current setup of the gridview is a SQL view that fills a dataset, which is then bound to the gridview. I have a column called 'Course', which is a column generated within the view that uses the Course_ID from the main User Table to lookup the Course name from the Course Table (see attachment). I would the Course column to be a combobox, when I auto generate the columns from the dataset it creates it as a textbox currently; and for the course names (from the course table) to be the options in the drop down . I would then like the user to see the selected options after a dataset update. Is there a way of doing this?

    Thank you.

  2. Daniel
    Daniel avatar
    5 posts
    Member since:
    Feb 2016

    Posted 28 Jun in reply to Daniel Link to this post

    VB.net if possible? 
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 29 Jun Link to this post

    Hello Daniel,

    Thank you for writing.

    You can display the data located in your Course table by adding a GridViewComboBox column  and binding that column to the table`s adapter. Detailed information is available here: GridViewComboBox Column. Pay attention to the ValueMemeber and FieldName properties of the column as they are important for the initial binding. The FieldName  will map the initial values for the combo box column to those already available after data binding the main grid.

    I am sending you an example in which I populated data from the sample Northwind database. I also added a GridViewComboBox column according to your scenario. Besides the project, I am also sending you a short video showing the result on my end.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
  5. Daniel
    Daniel avatar
    5 posts
    Member since:
    Feb 2016

    Posted 30 Jun Link to this post

    Thank you very much, I have managed to get it to work.

    FYI for anyone else reading this, you may need to manually create your bindingsource's linked to your tables in the dataset.

  6. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 30 Jun Link to this post

    Hi Daniel,

    Thank you for writing back.

    I am glad that I managed to help. 

    Please let me know if you need further assistance.

    Regards,
    Hristo Merdjanov
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready