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. Assign value to DataGridViewComboBoxCell at run-time

Assign value to DataGridViewComboBoxCell at run-time

Scheduled Pinned Locked Moved C#
databasehelp
2 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.
  • F Offline
    F Offline
    Fouad_kayali
    wrote on last edited by
    #1

    Dear Friends I've bound the DataGridViewComboBoxColumn to a table in Database, and I want programmatically to change the index of the selected item in the DataGridViewComboBoxCell, and I didn't find any property to do that kindly help me to do this...

    N 1 Reply Last reply
    0
    • F Fouad_kayali

      Dear Friends I've bound the DataGridViewComboBoxColumn to a table in Database, and I want programmatically to change the index of the selected item in the DataGridViewComboBoxCell, and I didn't find any property to do that kindly help me to do this...

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      Hello Your title was about assigning values. This means True or false valus to the cells. This is done simply by changing the DataGridViewCheckBoxCell.Value property to either true or false. OTOH in your post you said you want to change the index!! this is considered more with rows not columns. If you want to change the display index of a row -Move it up or down in the grid-:

      DataGridViewRow MyTempRow = MyDataGridView.Rows[OldIndex];
      MyDataGridView.Rows.RemoveAt(OldIndex); //Keeps it alive till you reinsert it
      MyDataGridView.Rows.Insert(NewIndex, MyTempRow);

      PS.I used OldIndex/NewIndex naming conventions just for the sake of clarity. If you want to get the first selected row use MyDataGridView.SelectedRows[0], provided that you check it is not null first.

      Regards:rose:

      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