如何在已经设计的Windows表单上访问DataGridView属性
我已经在上面设计了一个带有datagridview的Windows表单( form1 ),我还有一个带有一个带有一个按钮的功能区,当我单击它时,它可以在其中运行像Bellow这样的代码:
Private Sub Button2_Click(sender As Object, e As RibbonControlEventArgs) Handles
Button2.Click
Dim f As Form1
f = New Form1
f.Show()
'(Room for my question)
end sub
我希望能够访问我的DataGridView用户控件以编程添加列和行。
我应该怎么做?
I had already designed a windows form (Form1) with a DataGridView on it, I also have a ribbon with a button on it in which I want when I click on it, it run a code like bellow:
Private Sub Button2_Click(sender As Object, e As RibbonControlEventArgs) Handles
Button2.Click
Dim f As Form1
f = New Form1
f.Show()
'(Room for my question)
end sub
I want to be able to access my datagridview user control to add columns and rows programmatically.
How should I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在表单上创建一个公共子,您将在该表格上放置要进行的更改,然后在form2的button2_click事件上调用它。
例子:
表格1:
form2:
You can create a Public Sub on form one which where you will put the changes that you want make on the the Datagridview then call it on the Button2_Click event of your Form2.
Example:
Form 1:
Form2: