Results 1 to 7 of 7

Thread: [RESOLVED] [2005] combobox in datagridview, single click

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Resolved [RESOLVED] [2005] combobox in datagridview, single click

    Hello

    I have a combobox in my datagridview.

    But when I want to select from one of the items I have click about 3 times to select the item itself.

    Is there a way to single click on the combobox to that will make it drop down so that the user can select the item.

    Many thanks,

    Steve
    Attached Images Attached Images  
    steve

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: [2005] combobox in datagridview, single click

    In datagrid view the combox work on the single click event. I do not what are you doing there.
    Have you set the item in the datagridview combo?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: [2005] combobox in datagridview, single click

    Hello,

    I am not doing anything with the event of a cell being clicked.

    I just want to select an item from the combo box. Currently it takes about 3 clicks to do this. 1 for activating the cell, 2nd for activating the combo box adn dropping it, and 3rd selecting the item.

    I am wondering is there a way to cut down on the about of clicks that are needed.

    Thanks,
    steve

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: [2005] combobox in datagridview, single click

    As we know that the datagridview is the parent of the cell combobox
    so this will work from the parent to child

    and this combination will be as
    DataGridView -> DataGridViewRow -> DataGridViewcolumn

    for more detail you can see the datagridview click event!

    other wise it is batter to use a seperate combo for it!

  5. #5
    Addicted Member
    Join Date
    Nov 2006
    Posts
    204

    Re: [2005] combobox in datagridview, single click

    Try this, it works with 1 click:

    vb Code:
    1. Private Sub dgvReceiptItems_CellEnter( ByVal sender As Object, _
    2.  
    3.         ByVal e As System.Windows.Forms.DataGridViewCellEventArgs ) _
    4.  
    5.         Handles dgvReceiptItems.CellEnter
    6.  
    7.         Dim dgv As DataGridView = CType(sender, DataGridView)
    8.  
    9.  
    10.  
    11.         If dgv(e.ColumnIndex, e.RowIndex).EditType IsNot Nothing Then
    12.  
    13.             If dgv(e.ColumnIndex, e.RowIndex).EditType.ToString() = "System.Windows.Forms.DataGridViewComboBoxEditingControl" Then
    14.  
    15.                 SendKeys.Send("{F4}")
    16.  
    17.             End If
    18.  
    19.         End If
    20.  
    21.     End Sub

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: [2005] combobox in datagridview, single click

    There is a better way set the property EditMode to EditOnEnter

    Thanks
    steve

  7. #7
    New Member
    Join Date
    Mar 2018
    Posts
    1

    Re: [2005] combobox in datagridview, single click

    Quote Originally Posted by alex30 View Post
    Try this, it works with 1 click:

    vb Code:
    1. Private Sub dgvReceiptItems_CellEnter( ByVal sender As Object, _
    2.         ByVal e As System.Windows.Forms.DataGridViewCellEventArgs ) _
    3.         Handles dgvReceiptItems.CellEnter
    4.         Dim dgv As DataGridView = CType(sender, DataGridView)
    5.         If dgv(e.ColumnIndex, e.RowIndex).EditType IsNot Nothing Then
    6.             If dgv(e.ColumnIndex, e.RowIndex).EditType.ToString() = "System.Windows.Forms.DataGridViewComboBoxEditingControl" Then
    7.                 SendKeys.Send("{F4}")
    8.             End If
    9.         End If
    10.     End Sub
    This helped much !!! (even after 10 years LOL)

    Quote Originally Posted by steve_rm View Post
    There is a better way set the property EditMode to EditOnEnter

    Thanks
    This way with EditOnEnter works as well, but text in other cells can be easily changed after accidental key press.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width