How can i get i ShowDialog method in UserControl???
-
I want to extend then .net framewok's usercontrol,to make it has a showdialog like windows forms. How Can i get it??? Thanks a lot!!
Just like you would do it when not working on an
UserControl
:MainForm frm = new MainForm();
frm.ShowDialog(this); -
Just like you would do it when not working on an
UserControl
:MainForm frm = new MainForm();
frm.ShowDialog(this);Hi! I think you maybe mistake what i said! I mean the UserControl has the ShowDialog() method acts as the showdialog() method of the window forms. For example,there is a userControl instance: "usercontrol1",When I click a button,I call The usercontrol1's method usercontrol1.Showdialog(),and the usercontrol1 will be showed just like we show a Form instance with then showdialog() method.
-
Hi! I think you maybe mistake what i said! I mean the UserControl has the ShowDialog() method acts as the showdialog() method of the window forms. For example,there is a userControl instance: "usercontrol1",When I click a button,I call The usercontrol1's method usercontrol1.Showdialog(),and the usercontrol1 will be showed just like we show a Form instance with then showdialog() method.
Even I'm confused(not unusal). You want usercontrol1 to call showdialog on itself :confused: What's the point?
-
Hi! I think you maybe mistake what i said! I mean the UserControl has the ShowDialog() method acts as the showdialog() method of the window forms. For example,there is a userControl instance: "usercontrol1",When I click a button,I call The usercontrol1's method usercontrol1.Showdialog(),and the usercontrol1 will be showed just like we show a Form instance with then showdialog() method.
A control can't show itself as a dialog. This comes down to Windows styles and messages, since the
System.Windows.Forms
controls are just wrappers for native controls (Common Controls). You could add aShowDialog
method that adds the control to a borderless form and shows the form, but you can't show the control itself. It just isn't possible - it needs a Windows frame to host it. So you could do something like this:public void ShowDialog()
{
Form f = new Form();
f.FormBorderStyle = FormBorderStyle.None;
f.Size = this.Size;
f.Controls.Add(this);
f.ShowInTaskbar = false;
f.ShowDialog();
// Set properties or something.
f.Dispose(); // Always dispose modal dialogs when you're done with them
}-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Hi! I think you maybe mistake what i said! I mean the UserControl has the ShowDialog() method acts as the showdialog() method of the window forms. For example,there is a userControl instance: "usercontrol1",When I click a button,I call The usercontrol1's method usercontrol1.Showdialog(),and the usercontrol1 will be showed just like we show a Form instance with then showdialog() method.
If you just want to show or hide a
UserControl
, than you can use one of the following:- Call
Show
[^] to show the control, andHide
[^] to hide it again. - Set
Visible
[^] totrue
to show the control, and tofalse
to hide it again.
If you want to do something else, then please clarify it. - Daniƫl Pelsmaeker
This is Linux country. On a quiet night, you can hear NT re-boot.
- Call
-
A control can't show itself as a dialog. This comes down to Windows styles and messages, since the
System.Windows.Forms
controls are just wrappers for native controls (Common Controls). You could add aShowDialog
method that adds the control to a borderless form and shows the form, but you can't show the control itself. It just isn't possible - it needs a Windows frame to host it. So you could do something like this:public void ShowDialog()
{
Form f = new Form();
f.FormBorderStyle = FormBorderStyle.None;
f.Size = this.Size;
f.Controls.Add(this);
f.ShowInTaskbar = false;
f.ShowDialog();
// Set properties or something.
f.Dispose(); // Always dispose modal dialogs when you're done with them
}-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Hi Heath I have been trying this method to get access to the UITypeEditors, but I keep on gettting SEHExceptions, any ideas? Cheers :) leppie::AllocCPArticle("Zee blog");
Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.Not really. The description, "Represents Structured Exception Handler (SEH) errors.", doesn't even help much. I take it you're talking about the
UITypeEditor
s like the ColorEditor (or whatever that nifty one is) that are internal to the .NET BCL? Or just to host your own in a control?-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Not really. The description, "Represents Structured Exception Handler (SEH) errors.", doesn't even help much. I take it you're talking about the
UITypeEditor
s like the ColorEditor (or whatever that nifty one is) that are internal to the .NET BCL? Or just to host your own in a control?-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
Heath Stewart wrote: I take it you're talking about the UITypeEditors like the ColorEditor (or whatever that nifty one is) that are internal to the .NET BCL? Or just to host your own in a control? Well both, so I can use an existing infrastructure. And reuse my custom editors in the propertygrid again. Have a look at the nightmare of the propertygrid thru a disassembler. Things just dont make sense anymore. Like the "dropdownui" is a control hosted in a form hosted in a control. I mean crazy, and funny unsafe calls... maybe they made it intentionally like that! :mad: Also things like: TypeConvertor.EditValue() returns immediately, so u to somehow block it, without having access to the code, i say man, its a nitemare (R18) X| leppie::AllocCPArticle("Zee blog");
Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it. -
Not really. The description, "Represents Structured Exception Handler (SEH) errors.", doesn't even help much. I take it you're talking about the
UITypeEditor
s like the ColorEditor (or whatever that nifty one is) that are internal to the .NET BCL? Or just to host your own in a control?-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
The problem has been solved. Application.EnableVisualStyles() causes that error: http://groups.google.com/groups?num=20&hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8&q=SEHException[^] :) leppie::AllocCPArticle("Zee blog");
Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.