vb.net中起始位置的问题 [英] problem with start location in vb.net

查看:121
本文介绍了vb.net中起始位置的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我设计了一个表单,其起始位置为中心屏幕,在该表单中,当单击按钮时我有一个按钮,我实例化了另一个表单,其起始位置为中心父对象,但是发生的情况是该表单隐藏在先前创建的表单中,但是我需要它在它前面如何正确设置位置

谢谢

解决方案

您可以尝试BringToFront方法.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.bringtofront.aspx [ ^ ]


您的问题是什么?如果创建并显示一个新表单,它将根据需要放在第一个表单的顶部.如果可以覆盖第一种形式,那又如何呢?

顺便说一句,表单之间的父子关系是不起作用的(即使FormControlControl.Parent之间,并且您实际上可以将表单作为其他表单的父母,我建议您不要这样做),并且当然,您描述的两种形式不是儿童父母形式.

相反,我强烈建议使用所有者/拥有者"关系表.使用属性Form.Owner可使所有表单归主表单所有.这对于应用程序完整性很重要:激活一个表单或应用程序将始终将所有应用程序的表单按Z顺序激活在一起,这将不允许其他任何应用程序中的表单进入您的表单之间.

请参阅 http://msdn.microsoft.com/en-us/library/system .windows.forms.form.aspx [ ^ ].

更好的是,避免多种形式;仅将其中一个与更复杂的容器控件(例如TabControl)一起使用.现在,您单独的表单将成为选项卡页面.基于一种形式,还有许多其他好的样式.例如,以Visual Studio为例.这里最重要的是不使用MDI.

—SA


在我进行项目开发时,我也面临着同样的问题.
我找到了一个解决方案,只需创建一个Subrutine CloseAllOpenForm

 私有  Sub  CloseAllOpenForms()
Form1.Close()' 如果Form1打开,它将关闭Form1.
Form2.Close()' 如果打开,它将关闭Form2 
结束  


提及您在申请中使用的所有表格.
之后,要打开新表格,只需调用上述方法,如

 CloseAllForms()' 它将关闭所有打开的表单
Form1.Show()' 它将显示您新打开的表单. 


它将解决您的问题,因为没有其他表单被打开,只有您新打开的表单才会显示在MDI表单中.


hi
i have designed a form whose start position is centerscreen and in that form i have a button when the button is clicked i instantiate another form whose start position is center parent but what happens is this form gets hidden inside the previous form created but i need it in front of it how to set the position correctly

thanks

解决方案

You can try BringToFront method.
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.bringtofront.aspx[^]


What''s your problem? If you create and show a new form, it will go on top of the first form, as you wanted. If may cover the first form, so what?

By the way, parent-child relationship between forms is not functional (even though Form is Control with Control.Parent and you actually can make a form a parent of another form, I recommend you never do so), and the two forms you described are not child-parent, of course.

Instead, I strongly recommend to use the relationship Owner/Owned form. Use the property Form.Owner to make all forms owned by the main form. This is important for application integrity: activation of one form or application will always put all application''s form activate together in Z-order which will not allow a form from any other application to come between your forms.

See http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^].

Better yet, avoid multiple forms; use just one with more complex container controls like TabControl. What are now your separate form will become the tab pages. There are many other good styles based on a single form; look at Visual Studio, for example. Most important thing here is not using MDI.

—SA


I also faced the same proble at the time of my project Development.
I found one solution on that just create one Subrutine CloseAllOpenForm

Private Sub CloseAllOpenForms()
Form1.Close() 'It will Close Form1 if it is open.
Form2.Close() 'It will Close Form2 if it is open
End Sub


Mentione all forms you are using in your applicaiton.
After that befor opening new form just call above method like

CloseAllForms() 'It will close all open forms
Form1.Show()    'It will show your newly opened form.


It will Solve your problem because no other form is opened only your newly opened form will be shown in MDI Form.


这篇关于vb.net中起始位置的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆