CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2007

    Add selected Datagridview row of Form 2(child) to Datagridview cell of Form 1(Parent)

    Dear All Experts,

    I am new in VB.net. Your help will be really appreciating.

    I have two forms. Form1 and Form 2.

    I have opened the Form 2 from Form 1. By using this code.

    Button click event
    Dim F2 As New Form2

    In Form 2 there will be datagridview which is filled by dataset.

    Now i want to Add the datagridview selected cell value to Form 1 Datagridview by using click event. i can do this task in same form, but when form is different Form 2 data is not able to add in form 1.

    How to achieve this. Please provide the code for the same.


  2. #2
    Join Date
    Jul 2001
    Sunny South Africa

    Re: Add selected Datagridview row of Form 2(child) to Datagridview cell of Form 1(Par

    Not too difficult

    I'd ensure that my Form 2 functions as a normal Dialog box. This means add two buttons to Form 2, give them captions of OK and Cancel resepectively. Then, on Form2's Properties window, set the AcceptButton property to Button1 ( the OK button ) and CancelButton to Button2 ( the cancel button ), then show your Form2 as a dialog :

        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim F2 As New Form2
            If F2.ShowDialog = Windows.Forms.DialogResult.OK Then
            End If
        End Sub
    So, once OK has been clicked, the selected cell's value on Form 2 DGV will be added to the DGV on Form 1

    Make sense?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.