treeview Afterselect workaraound

P

Paul Palmero

Hi, reading some posts i found that is a known bug that the AfterSelect
event for a TreeView does not allow a newly created form to be sent to front
( it displays the form but the MainMenu is from the previous form).

eg:

Have Form1 and Form2 (both created : Form1 visible and Form2 hidden)

Form1 has a TreeView and in the AfterSelect event it does: Form2.Show() ,
Form1.Hide()

well, it shows form2 but the Main Menu is from Form1.


this behaviour does not happen when calling the show-hide methods from a
button click event.


I have tried to set the menu again ( Form2.Menu = theMenu), etc.. but no
go..

Any one has experienced this ?
Workaround ?

Thanks







Paul Palmero Dpto. sistemas
(e-mail address removed) --------------------------------------------
------------------------------------ - Este E-mail es confidencial. Según lo
previsto en la ley orgánica 15/1999 de la protección de los datos. Si usted
ha recibido este E-mail por error entonces pongase en contacto con nosotros
inmediatamente en (e-mail address removed) . Si usted no es el destinatario
previsto destruya por favor el correo y cualquier documento asociado
inmediatamente, pues no está autorizado y no debe divulgar, copiar,
distribuir o conservar todo o una parte de este E-mail sin nuestra
autorización. - This e-mail is confidential. It is intended for the
addressee(s)only according to the Statutory Data Protection Law 15/1999. If
you have received this e-mail in error then please contact us immediately at
(e-mail address removed) . If you are not the intended recipient please destroy
the mail and and any associated documents immediately, as you are not
authorised to & must not disclose, copy, distribute or retain all or part of
this e-mail without our authority. Appeyron Research s.a. -
(e-mail address removed) ----------------------------------------------------------
----------------------
 
P

Paul Palmero

S

Saul

Hi,

Yes, I hit this problem big time. Wasted hours because I thought I must be
doing something wrong!!

Anyway, my "solution" was perhaps a bit different to what has been suggested
so far. I use a timer and a boolean variable to get around it. The timer
checks the boolean, and if it's true, it opens the form. When the treeview
is selected, set the boolean to true. This works, as the timer has no
problem opening the form. Look, it's a hack, but it works, ok!! ;-)

Might be good for you.

- Saul
 
P

Paul Palmero

Hi, thanks for the input... as they say: there are many ways to skin a cat
!!

The bug affected my app in two way:

1. The form staying behind

2. The afterselect event kept firing when going back to the treeview form

Did point 2 afected anyone of you ?

I use cached forms.. i dont close and open the form again... so the event
keeps firing when
the form1 is shown, also i use a controller class to manage form interaction
etc.. so things
got complicated...

anyway.. my hack was a HACK !!..jeje.. not much time to make a better
solution
so its too ugly to post it here !! maybe in ""version 2.0"" ill look for a
better one.

i've put a little demo in windows forms (Yes !! happens in full framework
too)
reproducing the bug while using cached forms (to reproduce bug effect 2)

ill be glad to send it to anyone who asks for it..

Thanks to all,

Paul




Saul said:
Hi,

Yes, I hit this problem big time. Wasted hours because I thought I must be
doing something wrong!!

Anyway, my "solution" was perhaps a bit different to what has been suggested
so far. I use a timer and a boolean variable to get around it. The timer
checks the boolean, and if it's true, it opens the form. When the treeview
is selected, set the boolean to true. This works, as the timer has no
problem opening the form. Look, it's a hack, but it works, ok!! ;-)

Might be good for you.

- Saul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top