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. Problem with Datagridview Combobox column...

Problem with Datagridview Combobox column...

Scheduled Pinned Locked Moved Visual Basic
help
10 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.
  • R Offline
    R Offline
    RA UL PATEL
    wrote on last edited by
    #1

    I have added one combobox column to datagrid view in my windows application. In Combobox items added is 1,2,3,4,5 even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5 I want atleast one item must be displayed there in combo box by default. i.e There must be one selected item.

    D W A 3 Replies Last reply
    0
    • R RA UL PATEL

      I have added one combobox column to datagrid view in my windows application. In Combobox items added is 1,2,3,4,5 even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5 I want atleast one item must be displayed there in combo box by default. i.e There must be one selected item.

      D Offline
      D Offline
      darkelv
      wrote on last edited by
      #2

      Set SelectedIndex to other than -1 when you create the column. Is the column bound?

      R 1 Reply Last reply
      0
      • D darkelv

        Set SelectedIndex to other than -1 when you create the column. Is the column bound?

        R Offline
        R Offline
        RA UL PATEL
        wrote on last edited by
        #3

        first of all thanks for answer darkelv. For datagridview combobox column there is no selected index property. yes it is bound. I has set displaymember,Valuemember property according to i need it.

        D 1 Reply Last reply
        0
        • R RA UL PATEL

          I have added one combobox column to datagrid view in my windows application. In Combobox items added is 1,2,3,4,5 even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5 I want atleast one item must be displayed there in combo box by default. i.e There must be one selected item.

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          DataGridViewComboBoxColumn DataGridViewComboBoxCell doesn't have selectedindex or selectedvalue, so you must use Value property instead.

          The need to optimize rises from a bad design.My articles[^]

          modified on Friday, January 23, 2009 5:05 AM

          R 1 Reply Last reply
          0
          • R RA UL PATEL

            first of all thanks for answer darkelv. For datagridview combobox column there is no selected index property. yes it is bound. I has set displaymember,Valuemember property according to i need it.

            D Offline
            D Offline
            darkelv
            wrote on last edited by
            #5

            Maybe check if the binding is bound to the correct item/property. Here's a sample of my code that is bound to an array of enum Edit: Are you using comboBoxColumn.Items.Add() instead of setting DataSource?

            //==Status==//
            public static AtomDataGridViewComboBoxColumn StatusGridViewColumn(Atom.Interface.ILocale locale)
            {
            AtomDataGridViewComboBoxColumn status = new AtomDataGridViewComboBoxColumn();
            status.DataPropertyName = "Status";
            status.HeaderText = LocalText.GetText(locale, LocalID.Create("ChequePrint.Master.Cheque_Status"), "Status");
            status.Name = "Status";
            status.SortMode = DataGridViewColumnSortMode.Automatic;
            status.ReadOnly = false;
            status.Width = 90;
            status.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            status.DefaultCellStyle.Format = "";
            //===== MUST HANDLE DATA FILL FOR COMBO BOX HERE =====//
            #region .:BE831DCA-BCDC-4294-8634-E33D8C66E51E [Status]:.
            ArrayList a = new ArrayList();
            a.Add(StatusTypes.Outstanding);
            a.Add(StatusTypes.Issued);
            a.Add(StatusTypes.Cleared);
            a.Add(StatusTypes.Void);
            Array enums = a.ToArray(typeof(StatusTypes));
            //Array enums = Enum.GetValues(typeof(StatusTypes));
            status.DataSource = enums;
            #endregion .:BE831DCA-BCDC-4294-8634-E33D8C66E51E [Status]:.
            return status;
            }

            1 Reply Last reply
            0
            • W Wendelius

              DataGridViewComboBoxColumn DataGridViewComboBoxCell doesn't have selectedindex or selectedvalue, so you must use Value property instead.

              The need to optimize rises from a bad design.My articles[^]

              modified on Friday, January 23, 2009 5:05 AM

              R Offline
              R Offline
              RA UL PATEL
              wrote on last edited by
              #6

              Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.

              modified on Friday, January 23, 2009 6:11 AM

              W 1 Reply Last reply
              0
              • R RA UL PATEL

                Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.

                modified on Friday, January 23, 2009 6:11 AM

                W Offline
                W Offline
                Wendelius
                wrote on last edited by
                #7

                My bad, I didn't mean the column but the cell. DataGridViewComboBoxCell has the value property and it doesn't have selectedindex or selectedvalue.

                The need to optimize rises from a bad design.My articles[^]

                R 1 Reply Last reply
                0
                • W Wendelius

                  My bad, I didn't mean the column but the cell. DataGridViewComboBoxCell has the value property and it doesn't have selectedindex or selectedvalue.

                  The need to optimize rises from a bad design.My articles[^]

                  R Offline
                  R Offline
                  RA UL PATEL
                  wrote on last edited by
                  #8

                  Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.

                  W 1 Reply Last reply
                  0
                  • R RA UL PATEL

                    Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.

                    W Offline
                    W Offline
                    Wendelius
                    wrote on last edited by
                    #9

                    I don't quite understand your question. The DataGridViewComboBoxColumn represents the column itself while the cells is one cell in that column on a specified row. I think there's a very good example here: DataGridViewComboBoxColumn Class[^]

                    The need to optimize rises from a bad design.My articles[^]

                    1 Reply Last reply
                    0
                    • R RA UL PATEL

                      I have added one combobox column to datagrid view in my windows application. In Combobox items added is 1,2,3,4,5 even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5 I want atleast one item must be displayed there in combo box by default. i.e There must be one selected item.

                      A Offline
                      A Offline
                      Ashutosh Phoujdar
                      wrote on last edited by
                      #10

                      Can you please try this :

                      Dim rowCounter as Integer = 0
                      With CType(Grid.Rows(rowCounter).Cells(0), DataGridViewComboBoxCell)
                      .Items.Add("1")
                      .Items.Add("2")
                      .Items.Add("3")
                      .Items.Add("4")
                      .Value = .Items.Item(ind)
                      End With

                      Hope this will answer your query

                      dnpro "Very bad programmer" My Latest Articles RichTextBox Control with Find functionality LogViewer - A Simple Log Listening Utility

                      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