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. combo in datagridview

combo in datagridview

Scheduled Pinned Locked Moved Visual Basic
tutorial
5 Posts 4 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.
  • A Offline
    A Offline
    aphei
    wrote on last edited by
    #1

    hi all, how to fill a value to combo in datagridview thanks

    S R R 3 Replies Last reply
    0
    • A aphei

      hi all, how to fill a value to combo in datagridview thanks

      S Offline
      S Offline
      Sonia Gupta
      wrote on last edited by
      #2

      if u r asking for binding the combo box then here's the code dim con as new oledbconnection("connsctionsting") con.open dim ds as new dataset dim ad as new oledbdataadapter("query",con) ad.fill(ds) combobox1.displaymember="fieldname" combobox1.valuemember="fieldname" combobox1.datasource=ds.tables(0)

      1 Reply Last reply
      0
      • A aphei

        hi all, how to fill a value to combo in datagridview thanks

        R Offline
        R Offline
        Rupesh Kumar Swami
        wrote on last edited by
        #3

        Select Datagridview. Now Click on smart tag which is on top Right corner then select Option "Edit Column".Now select the column from selected column list which is of combo box type. Now Select Property Items(collection Type) and Press the associated button button.

        Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India)

        1 Reply Last reply
        0
        • A aphei

          hi all, how to fill a value to combo in datagridview thanks

          R Offline
          R Offline
          RichFeldman
          wrote on last edited by
          #4

          I'm not sure if this will answer your question, but the following code segment first creates a DataTable containing values for my combo box, then creates a column that is inserted into a datagrid. Dim typeDesc As New DataTable Dim dr As DataRow typeDesc.Columns.Add("Indx", Type.GetType("System.Int32")) '0 typeDesc.Columns.Add("Desc", Type.GetType("System.String")) '1 dr = typeDesc.NewRow() dr(0) = 0 : dr(1) = "Rural" typeDesc.Rows.Add(dr) dr = typeDesc.NewRow() dr(0) = 1 : dr(1) = "Suburban" typeDesc.Rows.Add(dr) dr = typeDesc.NewRow() dr(0) = 2 : dr(1) = "Urban" typeDesc.Rows.Add(dr) ' datatable giving values type newCol = New DataGridViewComboBoxColumn newCol.Width = 90 newCol.HeaderText = "Parcel Type" newCol.DataSource = typeDesc newCol.ValueMember = "Indx" newCol.DisplayMember = "Desc" dgvTasks.Columns.Insert(2, newCol) The dgvTasks is the name of the datagrid in which the combo will appear.

          Rich Feldman

          A 1 Reply Last reply
          0
          • R RichFeldman

            I'm not sure if this will answer your question, but the following code segment first creates a DataTable containing values for my combo box, then creates a column that is inserted into a datagrid. Dim typeDesc As New DataTable Dim dr As DataRow typeDesc.Columns.Add("Indx", Type.GetType("System.Int32")) '0 typeDesc.Columns.Add("Desc", Type.GetType("System.String")) '1 dr = typeDesc.NewRow() dr(0) = 0 : dr(1) = "Rural" typeDesc.Rows.Add(dr) dr = typeDesc.NewRow() dr(0) = 1 : dr(1) = "Suburban" typeDesc.Rows.Add(dr) dr = typeDesc.NewRow() dr(0) = 2 : dr(1) = "Urban" typeDesc.Rows.Add(dr) ' datatable giving values type newCol = New DataGridViewComboBoxColumn newCol.Width = 90 newCol.HeaderText = "Parcel Type" newCol.DataSource = typeDesc newCol.ValueMember = "Indx" newCol.DisplayMember = "Desc" dgvTasks.Columns.Insert(2, newCol) The dgvTasks is the name of the datagrid in which the combo will appear.

            Rich Feldman

            A Offline
            A Offline
            aphei
            wrote on last edited by
            #5

            thanks a lot Rich Feldman... your code is very help me to solve my problem...:)

            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