• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

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

1 Solution
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.

Ariful AmbiaHead of ITCommented:

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

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

Catch ex As Exception
End Try

        End Sub

Have Fun

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now