471,319 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Execute Code after showDialog()

Hi

I have a Windows Form (myForm()) doing somethig.
myForm() should be modal.
Normaly the action initated by user - pressing a Button, callling
myForm:DoSomething()

Now i will use the same Form like "batch-processing", starting
:DoSomething() in my code:

It'c clear to me that the following code can not work:

myForm:ShowDialog();
myForm:DoSomething()

--> what is the best way to do this ?

- Is there a "AfterShowEvent" ?, or which event is fired after dotnet
is "to be done doing everything with myDialog()"

- As well I think to use a timer....

Thanks
Peter

Nov 29 '05 #1
4 9933
Hi,
"Peter" <pR****@procom-gmbh.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
myForm:ShowDialog();
myForm:DoSomething()

--> what is the best way to do this ?


No clear why this cannot work, if you are going to implement it as a batch
it will have no user interaction, so most probably myForm will do something
(without requiring user interaction) and will return ( by calling
Form.Close ) so your code "may" work.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


Nov 30 '05 #2
If you're doing batch processing, why does the form need to be modal
(or shown at all)? Just create it, manipulate the form, and then
dispose it. Or use Show(), manipulate it, then close it.

If that won't work, you can add a VisibleChanged event to the form:

using (MyForm frm = new MyForm()) {
frm.VisibleChanged += new EventHandler(MyFormVisibleChanged);
frm.ShowDialog();
frm.VisibleChanged -= new EventHandler(MyFormVisibleChanged);
}
....
private void MyFormVisibleChanged(object sender, EventArgs e) {
MyForm frm = sender as MyForm;
if (frm != null && frm.Visible) {
// do something with frm
}
}

Jesse

Nov 30 '05 #3
Good Joke...

my Code should not run after the dialog is closed. I look for a
possibility to start code "from the outside of myDialog" when myDialog
is active.

myForm:Show();
myForm:DoSomething()

do this, but then myDialog ist not modal.

Peter.

Dec 2 '05 #4
Hi,

You have to use a thread then, I'm still not clear of what you want,
If you want that DoSmething() is executed when the dialog is being
displayed you have two potions:
1- call DoSomething in the Form_load of the dialog
2- use a thread
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Peter" <pR****@procom-gmbh.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Good Joke...

my Code should not run after the dialog is closed. I look for a
possibility to start code "from the outside of myDialog" when myDialog
is active.

myForm:Show();
myForm:DoSomething()

do this, but then myDialog ist not modal.

Peter.

Dec 2 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by trialproduct2004 | last post: by
reply views Thread by martin.bonneville | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.