receiving data from a datagrid control

hi i have two forms a and formb .In foram a am entering the data for employees.i have a button on the form a when i click it it shows form b and display the information of loacation in the data grid.what i am trying here is when i clikc any row on the datagrid,the value should be display in the form a

here is my code

in form b code
dim frmemployee as new frmemployee
frmemployee.txtlocationid.text=me.dgresults.item(me.dgresults.currentrowindex,0)


hariprasadereAsked:
Who is Participating?
 
Ariful AmbiaHead of MISCommented:
Hi

Here is your easiest solution.

First go to the property page of txtlocationid in frmemployee where u want to see the value. Change its Modifiers property to “Public”. Now write the following code in your other Form where u put your Grid


Private Sub Dgresults_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Dgresults.MouseDown

Try
Dim frmemployee As New Search
frmemployee. txtlocationid.Text = Me.Dgresults.Item(Me.Dgresults.CurrentRowIndex, 0)
            frmemployee.ShowDialog()

Catch ex As Exception
      MsgBox(ex.Message)
End Try

        End Sub

Have Fun
Noman
0
 
PreeceCommented:
I would use one form, with the edit fields at the top, and the datagrid below.  When you click an item in the datagrid control, then populate the edit fields.  Just be sure that if you were in the middle of an edit, to prompt for saving first before going to the new row and populating the edit fields, thus losing any unsaved info.  Also, when you create a new record or edit an existing one, once you click save, refresh the datagrid.

Preece
0
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.

All Courses

From novice to tech pro — start learning today.