Values only change when i use the mouse

Posted on 2015-02-12
Medium Priority
Last Modified: 2015-02-13
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.


    Public Sub Get_Weights(Active_Status)
        DataGridView1.DataSource = "null"
        sDataBaseString(2) = "data source=;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
            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
            bSource.DataSource = dbDataSet
            DataGridView1.DataSource = bSource
            command = New SqlCommand(query, cn)
            reader = command.ExecuteReader
        Catch ex As SqlException
        End Try

    End Sub

Open in new window

Question by:mustish1
1 Comment
LVL 34

Accepted Solution

Mike Eghtebas earned 2000 total points
ID: 40606893
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
    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
    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.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
Did you know PowerShell can save you time with SaaS platforms? Simply leverage RESTfulAPIs to build your own PowerShell modules. These will kill repetitive tickets and tabs, using the command Invoke-RestMethod. Tune into this webinar to learn how…

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question