locked
adding combobox for one cell into the datagrid

    Question

  •  

    Hi,

     

     

      I have created  datagridview in vb.net. and I want to create  combobox for one particular field or cell.how do i create that?. i used datagridviewcomboboxcolumn but then it shows combobox for whole column.  and i need  show combobox  for one pariticular cell.  

     

    can  anybody send  solution  using  vb.net  

     

    Thanks and regards,

    Mrudula  

     

     

    Wednesday, April 23, 2008 6:18 AM

Answers

  •  mrudula wrote:

    I have created  datagridview in vb.net. and I want to create combobox for one particular field or cell.how do i create that?. i used datagridviewcomboboxcolumn but then it shows combobox for whole column.  and i need  show combobox  for one pariticular cell.  

     

    Hi Mrudula,

     

    Here is code sample:

    Code Snippet

            Dim comboBoxCell As New DataGridViewComboBoxCell

            comboBoxCell.Items.Add("111")

            comboBoxCell.Items.Add("222")

            comboBoxCell.Items.Add("3")

         

            DataGridView1(0, 0) = comboBoxCell

     

    By the way,

    1. you can reference to specific cell like this: 

    DataGridView1.CurrentCell

    DataGridView1(RowIndex, ColumnIndex)

    DataGridView1.Rows(RowIndex).Cells(ColumnIndex)

     

    2. Get the position of current cell:

    DataGridView1.CurrentCellAddress

    dataGridView1.CurrentCell.RowIndex

    dataGridView1.CurrentCell.ColumnIndex

     

     

    Regards,

    Martin

    Tuesday, April 29, 2008 12:23 PM

All replies

  •  mrudula wrote:

    I have created  datagridview in vb.net. and I want to create combobox for one particular field or cell.how do i create that?. i used datagridviewcomboboxcolumn but then it shows combobox for whole column.  and i need  show combobox  for one pariticular cell.  

     

    Hi Mrudula,

     

    Here is code sample:

    Code Snippet

            Dim comboBoxCell As New DataGridViewComboBoxCell

            comboBoxCell.Items.Add("111")

            comboBoxCell.Items.Add("222")

            comboBoxCell.Items.Add("3")

         

            DataGridView1(0, 0) = comboBoxCell

     

    By the way,

    1. you can reference to specific cell like this: 

    DataGridView1.CurrentCell

    DataGridView1(RowIndex, ColumnIndex)

    DataGridView1.Rows(RowIndex).Cells(ColumnIndex)

     

    2. Get the position of current cell:

    DataGridView1.CurrentCellAddress

    dataGridView1.CurrentCell.RowIndex

    dataGridView1.CurrentCell.ColumnIndex

     

     

    Regards,

    Martin

    Tuesday, April 29, 2008 12:23 PM
  • In addition, this document may be helpful to you:

     

    http://msdn2.microsoft.com/en-us/library/7tas5c80.aspx

    How to: Host Controls in Windows Forms DataGridView Cells
    Tuesday, April 29, 2008 12:28 PM
  • Hi,

     

    i am very Inveresting in vb or vb.net programming and i am preparing for the big Project but there are meny Problems in that, i hope you will help me.

     

    i want to use combo box in datagrid with ado.net & dataset in vb.net but it is not seccess in my program so please send solution using vb.net

     

     

    Nilesh Zope

    nil_zope@rediffmail.com

    Monday, May 19, 2008 10:31 AM
  •  Nilesh1 wrote:

    i want to use combo box in datagrid with ado.net & dataset in vb.net but it is not success in my program.

     

    Hi Nilesh,
     

    I made a sample project covering your requirements:

    1.    Create manually DataGridView containing one ComboBox Cell.

    2.    Binding Database table to DataGridView with ADO.NET.

     

    I have sent the sample project to your Email. Please check it.

     

    By the way, there are many VB.NET code samples on Microsoft website.

    101 Visual Basic and C# Code Samples

    Visual Basic .NET Code Samples: Master Set of 101 Samples

     

    Regards,

    Martin

    Tuesday, May 20, 2008 8:42 AM
  •  

    hi,

     

    pl arrange to send who to add combobox in dagagrid coloum / cell in vb.net

     

    Nilesh

    nil_zope@rediffmail.com

    Tuesday, May 20, 2008 9:55 AM
  • Thanks,
    Saturday, February 13, 2010 2:26 AM
  • hi 

     Could u plz give me the complete code i.e, with an example in C# for adding a combobox in the datagridviewin winforms. I am a beginner so i am asking with example.

    thank u in advance

    Monday, June 07, 2010 6:36 PM
  • hi can you also send it to my email? or where can we download that sample project? =)
    thanks.. really need to learn about that combobox in a datagrid..
    thanks in advance
    farout9999@hotmail.com
    Tuesday, July 12, 2011 1:46 AM