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. use a Datagridviwcomboboxcell in a binded datagridview

use a Datagridviwcomboboxcell in a binded datagridview

Scheduled Pinned Locked Moved C#
helpquestion
6 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.
  • B Offline
    B Offline
    baranils
    wrote on last edited by
    #1

    Hello I have a datagridview binded to a datatable : Wine This datatable contains CepageID Cepage percent DGV shows Cepage and percent I have another datatable Cepages When the user wants to edit a cepage in the DGV I want to switch the textboxcell to a comboboxcell showing the different available cepages Is it possible with a binded datagridview ? Thanks for any help

    D 1 Reply Last reply
    0
    • B baranils

      Hello I have a datagridview binded to a datatable : Wine This datatable contains CepageID Cepage percent DGV shows Cepage and percent I have another datatable Cepages When the user wants to edit a cepage in the DGV I want to switch the textboxcell to a comboboxcell showing the different available cepages Is it possible with a binded datagridview ? Thanks for any help

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Why not use DataGridViewComboboxColumn right away?

      50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

      B 1 Reply Last reply
      0
      • D dan sh

        Why not use DataGridViewComboboxColumn right away?

        50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

        B Offline
        B Offline
        baranils
        wrote on last edited by
        #3

        Thanks for your answer ! I do not use Combobox column because I want to keep the normal textbox display when the cell is not editing ! Combobox display takes to much space in the grid to display the item properly !

        D 1 Reply Last reply
        0
        • B baranils

          Thanks for your answer ! I do not use Combobox column because I want to keep the normal textbox display when the cell is not editing ! Combobox display takes to much space in the grid to display the item properly !

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          Set these properties for your DataGridView as below:

          comboboxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
          yourDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;

          50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

          B 2 Replies Last reply
          0
          • D dan sh

            Set these properties for your DataGridView as below:

            comboboxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
            yourDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;

            50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

            B Offline
            B Offline
            baranils
            wrote on last edited by
            #5

            woaw that sounds great and so simple thank you I'll try it

            1 Reply Last reply
            0
            • D dan sh

              Set these properties for your DataGridView as below:

              comboboxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
              yourDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;

              50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

              B Offline
              B Offline
              baranils
              wrote on last edited by
              #6

              Hello d@nish Your suggestion was fine ! I've done it that way

                cbxCepage.DataSource = sCodes.dtCepages;
                cbxCepage.DisplayMember = "Value";
                cbxCepage.ValueMember = "ID";
                cbxCepage.DataPropertyName = "ID";
              
              
                dgvCepages.DataSource = null;
                dgvCepages.AutoGenerateColumns = false;
                dgvCepages.DataSource = Reg.Prod.dtCepages;
              
                dgvCepages.EditMode = DataGridViewEditMode.EditOnEnter;
                cbxCepage.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
              
              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