Windows窗体 - 通过ShowDialog()方法 [英] Windows Forms - Pass through the ShowDialog() method

查看:304
本文介绍了Windows窗体 - 通过ShowDialog()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列这样的命令:


Form1 frm = new Form1();

frm.LoadData();


布尔确认=(frm.ShowDialog()== DialogResult.OK);


LoadData方法从数据库加载信息。问题是,当我调试应用程序时,它没有显示表单。

。只是

通过ShowDialog()方法,我的标志确认变为

false,因为表单没有出现。可能会发生什么?


问候。


Junior。

I have a sequence of commands like this:

Form1 frm = new Form1();
frm.LoadData();

Boolean confirm = (frm.ShowDialog() == DialogResult.OK);

The LoadData method loads information from database. The problem is,
when I was debugging the application, it doesn''t show the form. It just
pass through the ShowDialog() method, and my flag confirm becomes
false, because the form does not appear. What can be happening?

Regards.

Junior.

推荐答案

在loaddata()之前添加frm.Show()方法


Raj


" osmarjunior"写道:
add frm.Show() method before the loaddata()

Raj

"osmarjunior" wrote:

我有一系列这样的命令:


Form1 frm = new Form1();

frm.LoadData();


布尔确认=(frm.ShowDialog()== DialogResult.OK);


LoadData方法从数据库加载信息。问题是,当我调试应用程序时,它没有显示表单。

。只是

通过ShowDialog()方法,我的标志确认变为

false,因为表单没有出现。可能会发生什么?


问候。


Junior。

I have a sequence of commands like this:

Form1 frm = new Form1();
frm.LoadData();

Boolean confirm = (frm.ShowDialog() == DialogResult.OK);

The LoadData method loads information from database. The problem is,
when I was debugging the application, it doesn''t show the form. It just
pass through the ShowDialog() method, and my flag confirm becomes
false, because the form does not appear. What can be happening?

Regards.

Junior.




好​​的。但我需要表单是Modal。


我对LoadData方法行发表了评论,并尝试了Show()

方法。表格似乎没问题。如果我通过ShowDialog()更改Show(),

表单正在关闭...我在FormClosed事件上放置了一个MessageBox来验证

...

有什么东西正在关闭表格,但我没有任何关于Load()或

显示该事件的事件......

Raj写道:

OK. But i need the form be Modal.

I put a comment on the LoadData method line, and I tried the Show()
method. The form appears ok. If I change Show() by ShowDialog(), the
form is closing... I put a MessageBox on FormClosed event to verify
that...

Something is closing the form, but I don''t have anything on Load() or
Shown() event of that form...
Raj wrote:

在loaddata()之前添加frm.Show()方法

Raj


" osmarjunior"写道:
add frm.Show() method before the loaddata()

Raj

"osmarjunior" wrote:

我有一系列这样的命令:


Form1 frm = new Form1();

frm.LoadData();


布尔确认=(frm.ShowDialog()== DialogResult.OK);


LoadData方法从数据库加载信息。问题是,当我调试应用程序时,它没有显示表单。

。只是

通过ShowDialog()方法,我的标志确认变为

false,因为表单没有出现。可能会发生什么?


问候。


Junior。
I have a sequence of commands like this:

Form1 frm = new Form1();
frm.LoadData();

Boolean confirm = (frm.ShowDialog() == DialogResult.OK);

The LoadData method loads information from database. The problem is,
when I was debugging the application, it doesn''t show the form. It just
pass through the ShowDialog() method, and my flag confirm becomes
false, because the form does not appear. What can be happening?

Regards.

Junior.


Junior,

你能发布一个简短但完整的程序来证明这个问题:
http://www.yoda.arachsys.com/csharp/complete.html


特别是Form1中阻止它显示的代码。


FWIW:我一直使用Form.ShowDialog&从未见过它没有显示

对话框。


-

希望这有帮助

Jay B. Harlow [MVP - Outlook]

..NET应用程序架构师,爱好者,&福音传教士

T.S.布拉德利 - http://www.tsbradley.net

" ; osmarjunior" < os ********* @ gmail.comwrote in message

news:11 ********************* @ b28g2000cwb.googlegro ups.com ...

|我有一系列这样的命令:

|

| Form1 frm = new Form1();

| frm.LoadData();

|

|布尔确认=(frm.ShowDialog()== DialogResult.OK);

|

| LoadData方法从数据库加载信息。问题是,

|当我调试应用程序时,它没有显示表单。它只是

|通过ShowDialog()方法,我的标志确认变为

| false,因为表单没有出现。可能会发生什么?

|

|问候。

|

|少年。

|
Junior,
Can you post a short but complete program that demonstrates the problem:
http://www.yoda.arachsys.com/csharp/complete.html

Specifically the code in Form1 that is preventing it from being shown.

FWIW: I use Form.ShowDialog all the time & have never seen it not display a
dialog.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"osmarjunior" <os*********@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
|I have a sequence of commands like this:
|
| Form1 frm = new Form1();
| frm.LoadData();
|
| Boolean confirm = (frm.ShowDialog() == DialogResult.OK);
|
| The LoadData method loads information from database. The problem is,
| when I was debugging the application, it doesn''t show the form. It just
| pass through the ShowDialog() method, and my flag confirm becomes
| false, because the form does not appear. What can be happening?
|
| Regards.
|
| Junior.
|


这篇关于Windows窗体 - 通过ShowDialog()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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