Results 1 to 5 of 5

Thread: DataGridView Combobox Control

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2010
    Posts
    50

    DataGridView Combobox Control

    Hi guys,

    Just wondering if there was a way of populating a DataGridView control during runtime so that in one column there could be a few rows set to type string followed by a combobox control cell all in the same column?

    Thanks

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: DataGridView Combobox Control

    No! Nor indeed at any time.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: DataGridView Combobox Control

    Yes that is completely possible and, in fact, at run time is the only time you can do it. When you add columns to a DataGridView you are specifying the template cell type for that column but, in fact, any cell in any column can be any type you want. You simply create a cell of the type you want and assign it to the grid's Item property, which gets or sets the cell at particular column and cell coordinates, e.g.
    Code:
    DataGridView1(1, 5) = New DataGridViewComboBoxCell()
    That will put a combo box cell in the second column of the sixth row regardless of the type of that column. The cell that was at that location will be discarded.

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2010
    Posts
    50

    Re: DataGridView Combobox Control

    Brilliant, works a charm thanks.

  5. #5
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: DataGridView Combobox Control

    You can? Darn it! Just when you think that darned DGV straight in your head ....
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width