Visual Studio刷新表单,以另一种形式 [英] Visual studio refresh form, when in another form
问题描述
我有两个名为frmmain和frmpopup的窗体。 frmpopup表单将数据添加到数据库和frmmain listview中。点击名为btnadd的按钮时。我需要在frmpopup表单上的btnadd按钮中刷新frmmain,所以当frmpopup关闭时。它将刷新frmmain加载表单,因此它将再次加载frmmain,我的数据将显示在列表视图中
我尝试过:
单击构建按钮时为frmmain格式btnadd
Dim popup As frmpopup
popup = 新 frmpopup
popup.ShowDialog(我)
popup.Dispose()
frmmain.refresh
i需要刷新frmmain格式
您不要从弹出窗体中执行此操作。弹出窗体应该只关注它自己的控件,而不是其他窗体的控件。
如果你用.ShowDialog()显示弹出窗体,主窗体当弹出窗体关闭时,可以编码刷新自己。
如果没有,你的弹出窗体应该被编码以引发主窗体订阅的事件。此事件将向任何听众发出数据已更改的信号,并且他们应该使用新数据刷新自己。
如果一个表单触及另一个表单的控件,则不会出现这种情况
I have 2 windows forms called frmmain and frmpopup. The frmpopup form is adding data into the database and to the frmmain listview. When clicking on button called btnadd. I need to refresh the frmmain with in the btnadd button on the frmpopup form, so when frmpopup closes. it will refresh the frmmain load form , so it will load the frmmain again and my data will show in the listview
What I have tried:
this is in frmmain form when clicking the build in button btnadd
Dim popup As frmpopup
popup = New frmpopup
popup.ShowDialog(Me)
popup.Dispose()
frmmain.refresh
i need to refresh the frmmain form
You do NOT do it from the popup form. The popup form should be concerned with just it's own controls, not the controls of other forms.
If you showed the popup form with .ShowDialog(), the main form can be coded to refresh itself when the popup form closes.
If not, your popup form should be coded to raise an event that the main form subscribes to. This event would signal any listeners that the data has changed and they should refresh themselves with the new data.
IN NO CASE should one form be touching the controls of another form.
这篇关于Visual Studio刷新表单,以另一种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!