Form.Activated not firing 
Author Message
 Form.Activated not firing

I call form.Activate from another form in my MdiApp however the activated
event is not firing.

I set a public string property in an object from the first form and then
call form.activate like this from within a foreach loop:

frm.so.StockRef = txtEwhRef.Text;
frm.Activate();

In the activated event of the second form I set the text of a label to this
string:

private void frmSalesOrder_Activated(object sender, System.EventArgs e)
{
     label1.Text = so.StockRef;

Quote:
}

'so' is my object. I know the object contains the string because if I make a
button on the form with the same code in its click event it changes the
label text just fine. I was trying to get around the user having to click a
'refresh' button to update the data on the form. The form comes to the front
correctly but the label doesn't change.

Any ideas?

Thanks

Morkai



Thu, 17 Feb 2005 05:19:24 GMT  
 Form.Activated not firing
Hi,



Quote:
> I call form.Activate from another form in my MdiApp however the
> activated event is not firing.

> I set a public string property in an object from the first form and
> then call form.activate like this from within a foreach loop:

> frm.so.StockRef = txtEwhRef.Text;
> frm.Activate();

> In the activated event of the second form I set the text of a label to
> this string:

> private void frmSalesOrder_Activated(object sender, System.EventArgs
> e) {
>      label1.Text = so.StockRef;
> }

> 'so' is my object. I know the object contains the string because if I
> make a button on the form with the same code in its click event it
> changes the label text just fine. I was trying to get around the user
> having to click a 'refresh' button to update the data on the form. The
> form comes to the front correctly but the label doesn't change.

> Any ideas?

> Thanks

> Morkai

As far as I know, the event 'Activated' have some problems... I've been in
the same case as you. The only solution I've found has been to catch the
window messages by overriding the 'WndProc' method as follows :

8<------------------------------------------------------------------------

protected override void WndProc(ref Message message)
{
  base.WndProc(ref message);
  switch (message.Msg)
  {
    case (int) Msg.WM_ACTIVATEAPP:
      // is that an activation or a desactivation ?
      if (message.WParam.ToInt32() == 1)
      {
        // this is an activation
        // Do what you have to do when the form is activated.
      }
      break;
    default:
      break;
  }

Quote:
}

8<------------------------------------------------------------------------

Hope this helps.

--

Caillet Frederic
Consultant at 3IE (Institut d'Innovation Informatique pour l'Entreprise)
c/o EPITA (French Computer Engineering School)



Fri, 18 Feb 2005 16:46:24 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ImageButton Click Event Handler Not Getting Fired, why not

2. Activating MDI child form on double click??

3. activate a new form from an mdiChild WITHIN the mdiContainer

4. Activate an MdiChild form?

5. Form.Activate error on WAP pages

6. How to catch events fired form OCX?

7. Firing events from a Windows Form controls

8. Events fired when a form is focused

9. 2 form or not 2 forms?

10. Client Activated vs Server Activated

11. UserControl does not show on running form and properies do not show

12. Activate Child AND NOT Deactivate Parent?

 

 
Powered by phpBB® Forum Software