C# 表单:锁定主表单并处理另一个表单
我想创造这样的东西。
当按钮单击主窗体时将锁定/禁用/不可访问。然后加载另一个表单并进行一些处理。 (实际上,当单击按钮时,它将从文件中读取一些文本并写入数据库。我放置进度条以提供美观的效果)
正如我所说,我想锁定/禁用/无法访问主窗体并加载另一个窗体。
我该怎么做?
请帮忙 约翰
I want to create something like this.
When the button clicks main form will lock/disable/inaccessible. Then the another form load and do some processing.
(actually when the button clicked, it will read some text from a file and write to db. I put progress bar to give a nice look)
As I said I want to lock/disable/inaccessible main form and load the another form.
How can I do this ?
Please Help
Yohan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
new Form().ShowDialog()
就可以做到这一点。new Form().ShowDialog()
will do just that.oldForm.Hide()
和newForm().ShowDialog()
oldForm.Hide()
andnewForm().ShowDialog()
正如 JN 提到的,ShowDialog 可以工作,但我认为您需要在打开的新表单中包含处理代码,因为程序只会在新表单完成并关闭后返回并“解锁”您的主表单。
编辑我刚刚看到原始帖子下面的评论,我想这已经被排序了,但我会在上面留下我的评论以防万一
as J.N. mentioned, ShowDialog will work, but I think you will need to have your processing code in the new form you open up, as the program will only return and 'unlock' your main form after the new form has finished and closed.
Edit I just saw the comments below the original post, I guess this has been sorted, but I'll leave my comments above just in case