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. DataGridView and ComboBoxes

DataGridView and ComboBoxes

Scheduled Pinned Locked Moved C#
csshelpannouncement
3 Posts 3 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.
  • C Offline
    C Offline
    crzyank
    wrote on last edited by
    #1

    Hello! I have a DataGridView object (not DataGrid) that has three DropDown ComboBoxes (cboOne, cboTwo and cboThree) in columns one,two and three. I need to update contents of cboTwo dynamically depending on the selection in cboOne on the same grid. Then based on selection from cboTwo, cboThree should change it's contents. Please consider that every row could have a different selection for cboOne that would impact available choices for cboTwo that in turn would impact contents of cboThree. I am just wondering if someone can help me out - if at all this is possible. Thank you. CrazyYankee

    L M 2 Replies Last reply
    0
    • C crzyank

      Hello! I have a DataGridView object (not DataGrid) that has three DropDown ComboBoxes (cboOne, cboTwo and cboThree) in columns one,two and three. I need to update contents of cboTwo dynamically depending on the selection in cboOne on the same grid. Then based on selection from cboTwo, cboThree should change it's contents. Please consider that every row could have a different selection for cboOne that would impact available choices for cboTwo that in turn would impact contents of cboThree. I am just wondering if someone can help me out - if at all this is possible. Thank you. CrazyYankee

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      crzyank wrote:

      if at all this is possible.

      DataGridView ComboBox column Source DataBinding is Column based not row based. I beleive you would have to write your own data binding mechanism to accomplish that.

      led mike

      1 Reply Last reply
      0
      • C crzyank

        Hello! I have a DataGridView object (not DataGrid) that has three DropDown ComboBoxes (cboOne, cboTwo and cboThree) in columns one,two and three. I need to update contents of cboTwo dynamically depending on the selection in cboOne on the same grid. Then based on selection from cboTwo, cboThree should change it's contents. Please consider that every row could have a different selection for cboOne that would impact available choices for cboTwo that in turn would impact contents of cboThree. I am just wondering if someone can help me out - if at all this is possible. Thank you. CrazyYankee

        M Offline
        M Offline
        M Cahid AYDIN
        wrote on last edited by
        #3

        You can use CellValueChanged event of dataGridView and write some code in this event. i make a sample of code you must know the index of col1 which will effect the values of col2. this code is getting the object of cell1 and remove it from cell2 private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1) { object _value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; ((DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells[2]).Items.Remove(_value); } } i hope this will help you

        mca

        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