-
September 14th, 2013, 04:05 AM
#1
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
F2.Show()
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.
Thanks,
AKM
-
September 18th, 2013, 04:02 AM
#2
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 :
Code:
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
DataGridView1.Rows.Add(F2.DataGridView1.CurrentCell.Value.ToString)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|