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. Visual Basic
  4. datagridview ?

datagridview ?

Scheduled Pinned Locked Moved Visual Basic
helpdesigntutorialquestion
4 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.
  • M Offline
    M Offline
    moomoooomoo
    wrote on last edited by
    #1

    greeting again friends, i again need your help... as always it's badly needed... my problem is, when i change the column type into a comboboxcolumn i can only change it from design time.. 1.) how to change the columns using datagridview into a comboboxcolumn at runtime? 2.) how to populate the comboboxcolumn at runtime? from codes... links/ site/codes are highly appreciated... thank you.. :-D

    start a new beginning in every ending; thats what life for......

    D 1 Reply Last reply
    0
    • M moomoooomoo

      greeting again friends, i again need your help... as always it's badly needed... my problem is, when i change the column type into a comboboxcolumn i can only change it from design time.. 1.) how to change the columns using datagridview into a comboboxcolumn at runtime? 2.) how to populate the comboboxcolumn at runtime? from codes... links/ site/codes are highly appreciated... thank you.. :-D

      start a new beginning in every ending; thats what life for......

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      moomoooomoo wrote:

      1.) how to change the columns using datagridview into a comboboxcolumn at runtime?

      Create your own columns instead of relying on the designer to do it for you. You can't "modify" an exsting column. It has to be removed and replaced by one your code creates.

      moomoooomoo wrote:

      2.) how to populate the comboboxcolumn at runtime? from codes...

      That depends on where the data is comming from that your trying to populate it with. Is it from a table in the database?? From a file?? Some data you have hard-coded?? Without further information, this[^] is about the best anyone can tell you.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        moomoooomoo wrote:

        1.) how to change the columns using datagridview into a comboboxcolumn at runtime?

        Create your own columns instead of relying on the designer to do it for you. You can't "modify" an exsting column. It has to be removed and replaced by one your code creates.

        moomoooomoo wrote:

        2.) how to populate the comboboxcolumn at runtime? from codes...

        That depends on where the data is comming from that your trying to populate it with. Is it from a table in the database?? From a file?? Some data you have hard-coded?? Without further information, this[^] is about the best anyone can tell you.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        M Offline
        M Offline
        moomoooomoo
        wrote on last edited by
        #3

        the data should come from sql database...

        start a new beginning in every ending; thats what life for......

        D 1 Reply Last reply
        0
        • M moomoooomoo

          the data should come from sql database...

          start a new beginning in every ending; thats what life for......

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Create a second DataTable object with the ID's and Data of the items that are going to appear in the ComboBoxColumn. Then create a new DataGridViewComboBoxColumn and bind it to this table.

          ' Retrieve the data for the combobox
          Dim DataForCombo As DataTable = SQLStuff.GetDate()
          
          ' Create a new ComboBox column 
          Dim col As New DataGridViewComboBoxColumn
          With col
              .HeaderText = "Column Header in DGV"
              .DataPropertyName = "_ID column name in the table the DGV is showing_"
              .DataSource = DataForCombo
              .ValueMember = "_ID column name in DataForCombo table_"
              .DisplayMember = "_Column name for the data shown to the user in the ComboBox_"
          End With
          DataGridView1.Columns.Add(col)
          

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          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