dcsimg
Results 1 to 4 of 4

Thread: Add combobox to datagridview and set default value from data table

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2019
    Posts
    3

    Add combobox to datagridview and set default value from data table

    Hi All,

    I have a form in which the user is going to update a datagridview combobox with a selection. I have tied the items in the combobox to a sql database table. These are the dropdown selections.

    Unit(s) Missing
    Gate Locked
    Too Muddy
    Swap
    Repair
    No Issue

    I can load them, and fire an event on change to update a database table with the selected value. My question is, is there a way to set the default value of the selected item in the combox to the value that was previously saved, (this form is loaded multiple times during the users session to collect survey data) while also loading the other selection options so the user can update if they saved the wrong value?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,085

    Re: Add combobox to datagridview and set default value from data table

    Thread moved from the 'CodeBank VB.Net' forum (which is for you to post working code examples, not questions) to the 'VB.Net' forum

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,724

    Re: Add combobox to datagridview and set default value from data table

    If that's not happening automatically then you're doing it wrong. Follow the CodeBank link in my signature and check out my thread on adding a ComboBox column to a DataGridView. That's the appropriate use of the CodeBank forum.

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,167

    Re: Add combobox to datagridview and set default value from data table

    How is the data in the datagridview loaded. I mean, what is the dgv datasource? Do you set the datasource property to a datatable or bindingsource? Or do you manually add data to the dgv on row at a time?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width