Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DataGridViewComboBoxColumn, how the bound dataset into the datagridview.

DataGridViewComboBoxColumn, how the bound dataset into the datagridview.

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leeoze 0
    wrote on last edited by
    #1

    Hi, I have dataset that is bound to a DataGridView. In my DataSet I have column "name" (string) and column "sex" (int). So far so good. My problem is: Now I need to convert "sex" to a comboBox type with values 0-> male, 1->female. any ideas? tnx

    B 1 Reply Last reply
    0
    • L leeoze 0

      Hi, I have dataset that is bound to a DataGridView. In my DataSet I have column "name" (string) and column "sex" (int). So far so good. My problem is: Now I need to convert "sex" to a comboBox type with values 0-> male, 1->female. any ideas? tnx

      B Offline
      B Offline
      basambora
      wrote on last edited by
      #2

      Hi, If you want to do it the hard way, you could choose to set VirtualMode[^] to true. And use a DataGridViewComboBoxColumn[^]. However then you have to manage your datastore manually and all other related functions (including drawing the datagridview). This offers a great deal of flexibility, but is rather complex (though the msdn does give a very nice example). You could also try to replace the column from the datagridview with a DataGridViewComboBoxColumn, but I don't know how to link the dataset to your column then. Greets, basambora

      L 1 Reply Last reply
      0
      • B basambora

        Hi, If you want to do it the hard way, you could choose to set VirtualMode[^] to true. And use a DataGridViewComboBoxColumn[^]. However then you have to manage your datastore manually and all other related functions (including drawing the datagridview). This offers a great deal of flexibility, but is rather complex (though the msdn does give a very nice example). You could also try to replace the column from the datagridview with a DataGridViewComboBoxColumn, but I don't know how to link the dataset to your column then. Greets, basambora

        L Offline
        L Offline
        leeoze 0
        wrote on last edited by
        #3

        I've created a DataGridViewComboBoxColumn named "cbx". Added 0->"male",1->"female" to it's items; I've added the "cbx" to my GridView as "sexA" column and for each row I "sexA".value = "sex".value; i used this line: gridview.Rows[0].Cells["sexA"].value = gridview.Rows[0].Cells["sex"].value; Just as a remainder, "sex" is int type and also the "cbx" value is int type. thought the results should be to show the displaymember on "sexA" by the value of "sex" it doesn't show anything on "sexA". Although later on I can edit and select a new value to "sexA" but can't do that using code! it's seems like it doesn't update the gridview. I tried GridView.Refresh(). Any ideas? tnx

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups