receiving data from a datagrid control

Posted on 2006-06-05
Last Modified: 2010-04-17
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

Question by:hariprasadere
    LVL 12

    Expert Comment

    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.

    LVL 4

    Accepted Solution


    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Title # Comments Views Activity
    either24  challenge 19 73
    WMI, model #, retrieving information 10 52
    firstChar challenge 13 55
    Arduino EDI - Programming language 3 29
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This is an explanation of a simple data model to help parse a JSON feed
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now