操作控件在父窗体从子VB.NET
问题描述:
我想一个新行从表格2添加到一个DataGridView,但我能不能成功,我试过代码如下:操作控件在父窗体从子VB.NET
FORM 2:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FORM1.invoice_items.Rows.Add()
End Sub
看起来需要时间但找不到解决方案,有人可以帮我解决我的问题,谢谢。
答
试试这个 只有当您使用showdialog时,才能使用此工作。
表2:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Pass the value to be added in the datagrid to form 1
Me.DialogResult=Windows.Forms.DialogResult.OK
End Sub
表1:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Form2.ShowDialog = Windows.Forms.DialogResult.OK Then
'Getthe value from form 2
invoice_items.Rows.Add()
End If
End Sub
+0
你的答案帮助我很多谢谢:) + Rep – 2012-03-06 17:40:11
这是形式2显示对话框的形式? – 2012-03-06 15:59:52