VB.NET Controls inside a DataGridView row in a Windows form

I have a ComboBox inside a DataGridView Row cell in a Windows form. I need the following:

  • click on combobox
  • select value
  • recalculate the total and display inside the sheet lying on the table outside the DataGridView.

The following is currently happening:

  • Click on ComboBox
  • Click it again to open the CB drop-down list.
  • select value
  • click outside the cell to force recalculation of the outer label.

I want to avoid, firstly, pressing the combination twice (set the focus once and select the value again). Secondly, I would like to recalculate the live sound after selecting a value.

Does anyone have a trick or two to solve any of these problems?

I tried most events on DGV without much luck.

0
2

CellClick DataGridView, :

private void vehicleTypeGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
    if ( e.RowIndex == - 1 ) return; //Header Cell clicked -> ignore it.
    vehicleTypeGridView.BeginEdit ( true );
    var control = vehicleTypeGridView.EditingControl as DataGridViewComboBoxEditingControl;
    if ( control != null ) control.DroppedDown = true;
}
+3

-, datagridview:

datagridview.EditMode = Windows.Forms.DataGridViewEditMode.EditOnEnter

F4 :

Private Sub datagridview_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs)
        Handles datagridview.EditingControlShowing
    Dim CB As Object = TryCast(e.Control, System.Windows.Forms.ComboBox)
    If CB IsNot Nothing Then
        My.Computer.Keyboard.SendKeys("{F4}")
    End If
End Sub
+1

All Articles