Values only change when i use the mouse

Hi guys: Is there any way I can change these values by means of using the arow keys as right now they only change in the textboxes when I use the mouse.

Thanks

s
    Public Sub Get_Weights(Active_Status)
        DataGridView1.DataSource = "null"
        sDataBaseString(2) = "data source=175.16.64.3;user id=sa;password=;initial catalog=processtwo"
        Dim strConnection As String = sDataBaseString(2)
        Dim cn As SqlConnection = New SqlConnection(strConnection)
        Dim bSource As New BindingSource
        DataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        Try
            cn.Open()
            query = "select BarcodeType as Tank, Active as Active, Description as Description, ContractWeight as 'Contract Weight', ComponetWeight as 'Component Weight', WatchTolerance as 'Watch Tolerance', LimitTolerance as 'Limit Tolerance', convert(float, ComponetWeight)+convert(float, ContractWeight) as 'Target Weight' from Weights " & Active_Status
            command = New SqlCommand(query, cn)
            sda.SelectCommand = command
            sda.Fill(dbDataSet)
            bSource.DataSource = dbDataSet
            DataGridView1.DataSource = bSource
            'sda.Update(dbDataSet)
            command = New SqlCommand(query, cn)
            reader = command.ExecuteReader
        Catch ex As SqlException
            MessageBox.Show(ex.Message)
        Finally
            cn.Dispose()
        End Try

    End Sub

Open in new window

mustish1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:
I have tested the following and it work but you need to use the concept and make it work for your project:

Private Sub TblCustomersDataGridView_RowEnter(sender As Object, e As DataGridViewCellEventArgs) Handles TblCustomersDataGridView.RowEnter
        FireMyEvent(Me.TblCustomersDataGridView.Rows(e.RowIndex).Cells(1).Value)
    End Sub
    Private Sub FireMyEvent(strTemp As String)
        Me.CityTextBox.Text = strTemp
    End Sub
    Private Sub TblCustomersDataGridView_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles TblCustomersDataGridView.CellClick
        FireMyEvent(Me.TblCustomersDataGridView.Rows(e.RowIndex).Cells(1).Value)
    End Sub

Open in new window


You have CellClick event working for you now via mouse click. Is this correct?

If so, make a new sub (I have called it FireMyEvent in my sample). And move your existing code from CellClick to FireMyEvent . Of course you need to call  FireMyEvent from your existing CellClick with required parameters.

Test it and make sure it works as before just using mouse click.

Now, activate your datagridview RowEnter event.  Then add to this event the FireMyEvent method the same as the one you just added to CellClick event.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.