Hi all,

  1. My DataGridview is populated and displays the data correctly. No Problem here.
  2. I use the Up/Down Key to navigate in the DataGridview and the rows get highlighted when I pass over them. No problem here.

This is what I would like to code if posible:

  1. What I would like to do is that when using the arrow Up/Down key and on the Datgridview Row Enter Event that a simulated Mouse click be executed on that row.

The reason:

Currently when I click on a row on the Datagridview a calculation is performs and is displayed the results on a Label text. (This is currently working on the Datagridview click event.)

Unfortunatly on the Datagridrow Row Enter the code won't execute.

Is this even possible?

Regards,

Resolve it using this code.

'Assigns the variable todays from my form display date text [/COLOR]
    Dim todaysdate As DateTime = Me.lblTodayDate.Text

    ‘Assigns the date from the column that holds the date needed to the label lblRowCellDate
    lblRowCellDate.Text = dgvEdit.SelectedRows(0).Cells(27).Value

    ‘Assigns the variable WRRTYEnddate the datefrom the label lblRowCellDate
    Dim WRRTYEnddate As DateTime = Me. lblRowCellDate.Text

    ‘ Assigns the variable DaysLeft the days that the two dates have (date from lblRowCellDate and todays date)
    Dim DaysLeft As Int32 = departuredate.Subtract(todaysdate).Days

    ‘ Assigns the variable s2 the results of the calculation and conversion.
    Dim s2 As String = Convert.ToString(DaysLeft)

    ‘ Assigns the label lblDaysleft the results
    lblDaysleft.Text = s2

Basically I added a Button with the code below. And call the button with Button Run Code Click Perform Click from the RowEnter Event of the datagrid.

I hope this helps others.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.