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. plz help me with datagridview question

plz help me with datagridview question

Scheduled Pinned Locked Moved C#
questionhelp
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
    akkram
    wrote on last edited by
    #1

    Hi, I have a DataTable with 4 columns (id, type, length and note) which i bind to a DataGridView (mydataGridView.DataSource = mydataset.Tables[0]. How can I make the "type" column in my datagridview a DataGridViewComboBoxColumn with 3 values (say "white", "black", "gray") representing the same values stored in the DataTable type column? Any help would really be appreciated.

    N P K 3 Replies Last reply
    0
    • A akkram

      Hi, I have a DataTable with 4 columns (id, type, length and note) which i bind to a DataGridView (mydataGridView.DataSource = mydataset.Tables[0]. How can I make the "type" column in my datagridview a DataGridViewComboBoxColumn with 3 values (say "white", "black", "gray") representing the same values stored in the DataTable type column? Any help would really be appreciated.

      N Offline
      N Offline
      NaNg15241
      wrote on last edited by
      #2

      I don't know how to do it with the MS DataGridView. But there are plenty of open sources grid views that can do that. I'd try to search in codeproject for some. I also recommend that you'll look at this: http://www.codeproject.com/cs/miscctrl/csharpgridcontrol.asp[^] NaNg.

      1 Reply Last reply
      0
      • A akkram

        Hi, I have a DataTable with 4 columns (id, type, length and note) which i bind to a DataGridView (mydataGridView.DataSource = mydataset.Tables[0]. How can I make the "type" column in my datagridview a DataGridViewComboBoxColumn with 3 values (say "white", "black", "gray") representing the same values stored in the DataTable type column? Any help would really be appreciated.

        P Offline
        P Offline
        Pualee
        wrote on last edited by
        #3

        http://72.14.209.104/search?q=cache:trF3gRxXd5wJ:www.windowsforms.net/Samples/Go%2520To%2520Market/DataGridView/DataGridView%2520FAQ.doc+dataGridview+autogeneratecolumns&hl=en&ct=clnk&cd=3&gl=us[^] This always answers my questions, I suggest looking there first (I DLed the doc at the top). That said, I have never figured out your problem, I just did a work around: 1. Create an unbound DataGridViewComboBoxColumn 2. Fill it with your selectable values 3. Add it to your DataGridView 4. Set its value based on the bound column 5. Hide the bound column 6. Create a CellValueChanged event 7. On changing the unbound column value, update the bound column If you are dead set on putting the bound column as a combo box, I think you would have to pre-populate your columns in the datagridview prior to binding your datasource (3 textboxes and 1 combobox appropriately named), otherwise I have no success trying to change the DataGridViewTextBoxColumn (default) to ComboBox. Good Luck Pualee -- modified at 0:30 Monday 23rd April, 2007

        P 1 Reply Last reply
        0
        • P Pualee

          http://72.14.209.104/search?q=cache:trF3gRxXd5wJ:www.windowsforms.net/Samples/Go%2520To%2520Market/DataGridView/DataGridView%2520FAQ.doc+dataGridview+autogeneratecolumns&hl=en&ct=clnk&cd=3&gl=us[^] This always answers my questions, I suggest looking there first (I DLed the doc at the top). That said, I have never figured out your problem, I just did a work around: 1. Create an unbound DataGridViewComboBoxColumn 2. Fill it with your selectable values 3. Add it to your DataGridView 4. Set its value based on the bound column 5. Hide the bound column 6. Create a CellValueChanged event 7. On changing the unbound column value, update the bound column If you are dead set on putting the bound column as a combo box, I think you would have to pre-populate your columns in the datagridview prior to binding your datasource (3 textboxes and 1 combobox appropriately named), otherwise I have no success trying to change the DataGridViewTextBoxColumn (default) to ComboBox. Good Luck Pualee -- modified at 0:30 Monday 23rd April, 2007

          P Offline
          P Offline
          Pualee
          wrote on last edited by
          #4

          Pualee wrote:

          If you are dead set on putting the bound column as a combo box, I think you would have to pre-populate your columns in the datagridview prior to binding your datasource (3 textboxes and 1 combobox appropriately named), otherwise I have no success trying to change the DataGridViewTextBoxColumn (default) to ComboBox.

          You can add the columns at design time or run time. At design time, try the "Columns" property in the IDE. You can type the column name and select type. Pualee

          1 Reply Last reply
          0
          • A akkram

            Hi, I have a DataTable with 4 columns (id, type, length and note) which i bind to a DataGridView (mydataGridView.DataSource = mydataset.Tables[0]. How can I make the "type" column in my datagridview a DataGridViewComboBoxColumn with 3 values (say "white", "black", "gray") representing the same values stored in the DataTable type column? Any help would really be appreciated.

            K Offline
            K Offline
            Keshav V Kamat 0
            wrote on last edited by
            #5

            this would be the best article to explain the same http://www.codeproject.com/cs/miscctrl/RenDataGridComboBoxColumn.asp[^]

            Keshav Kamat :) India

            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