gpt4 book ai didi

vb.net - 从子 VB.NET 操作父窗体上的控件

转载 作者:行者123 更新时间:2023-12-04 05:55:12 24 4
gpt4 key购买 nike

我正在尝试从 FORM 2 向 DataGridView 添加新行,但无法成功,我尝试的代码如下:

表格 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

表格一:
  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

关于vb.net - 从子 VB.NET 操作父窗体上的控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9587005/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com