Re: Testing for Modal form
From: Mark Broadbent (no-spam-please_at_no-spam-please.com)
Date: 05/02/04
- Next message: Uri Dor: "Re: Testing for Modal form"
- Previous message: Mark Broadbent: "Re: Testing for Modal form"
- In reply to: Mark Broadbent: "Re: Testing for Modal form"
- Next in thread: Uri Dor: "Re: Testing for Modal form"
- Reply: Uri Dor: "Re: Testing for Modal form"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 2 May 2004 12:00:36 +0100
p.s. "private void myForm_Load" should have read "private void Form_Load"
--
--
Br,
Mark Broadbent
mcdba , mcse+i
=============
"Mark Broadbent" <no-spam-please@no-spam-please.com> wrote in message
news:Oxni4PDMEHA.2532@TK2MSFTNGP10.phx.gbl...
> well the problem lies with the code (theres a suprise :). The form is
> instanciated by another form's button click event. The delegate that I
added
> to this new form uses "this" which seems to be referring back to parent
> form.
> Which raises a new problem (please first see code)
> private void button1_Click(object sender, System.EventArgs e){
>
> Form myForm = new Form();
>
> myForm.Load += new System.EventHandler(Form_Load);
>
>
> myForm.ShowDialog();
>
> }
>
>
> private void myForm_Load(object sender, System.EventArgs e){
>
> if (this.Modal) MessageBox.Show("Modal");
>
> else MessageBox.Show("Modeless");
>
> }
>
> I was under the impression that "this" referred to the current instance,
but
> when running the above code you will see that the delegate myForm_Load
that
> is added to the new forms Load event refers to the object instance of the
> class that the delegate code myForm_Load belongs. If this is true then how
> could I programmatically add a delegate method to the new form's load
event
> that refers to the this new form (without actually creating a separate
> class module for the new forms definition)?
>
> --
>
> Br,
> Mark Broadbent
> mcdba , mcse+i
> =============
> "Mark Broadbent" <no-spam-please@no-spam-please.com> wrote in message
> news:eDoEO3CMEHA.2584@TK2MSFTNGP12.phx.gbl...
> > I am instantiating a form and calling it via the ShowDialog method. I am
> > testing for the forms modal property within it's Load event but the
modal
> > property is always false.
> > Supposedly you can test for the modal property within Load event and
above
> > (but it doesn't work in constructor by design). I get the same modal
> result
> > when showing a form via its Show method too.
> >
> > Expected behaviour is
> > ShowDialog modal=true
> > Show modal=false
> >
> > So why is this going wrong?
> >
> > --
> >
> > --
> >
> > Br,
> > Mark Broadbent
> > mcdba , mcse+i
> > =============
> >
> >
>
>
- Next message: Uri Dor: "Re: Testing for Modal form"
- Previous message: Mark Broadbent: "Re: Testing for Modal form"
- In reply to: Mark Broadbent: "Re: Testing for Modal form"
- Next in thread: Uri Dor: "Re: Testing for Modal form"
- Reply: Uri Dor: "Re: Testing for Modal form"
- Messages sorted by: [ date ] [ thread ]