Unable to show a form

  • Thread starter Thread starter Saul
  • Start date Start date
S

Saul

Hi all.

I am fairly new to VB.NET development in the compact framework, but I
think I'm starting to get the hang of it. Anyway, I have a program in
development that has multiple forms. One form shows a whole lot of
products in a treeview. When the user selects the product, a detailed
product screen is displayed. Or at least, that is how it is supposed
to work.

so, in the treeProduct_Afterselect event I have
'Read the tag and do some other stuff then..
dim myfrmDetail as frmDetail
frmDetail.show()

The problem is that the detail form is displayed BEHIND the treeview
form. Actually, while stepping through the code it starts to display
some of the detailed forms text fields (over the treeview content),
but then these simply disappear and you are left looking at the
treeview form again, like nothing happened. If you close the treview
form, the detail form is sitting there as happy as larry.

This is the 4th/5th form deep in my application (and the last one
grrrr). It is really driving me nuts. I have tried quite a few things
to fix this, and have read a lot online about similar problems. I have
tried opening a test form with just a button on it and this does the
same thing - so I don't think it's a but in the detail form itself. I
have also tried frmDetail.bringtofront() but that doesn't do anything.
I have tried to hide the treeview form as well, that also seems to not
work.

I can't see what's wrong with my call to open the window, and am
wondering if it's because I am doing this from within a treeview
event. Actually, this treeview is also on a tab page, but I don't
think that should matter. Not sure.

Anyone with any suggestions are greatly appreciated. Like I said, this
one is driving me nuts, and I've wasted a day on it already.

Regards,
Saul
 
All,

Further testing really strongly points me to this conclusion --

You can not open another form from a treeview Afterselect event. At least,
it does not open in front of the calling form.

I don't know why this is. Can anyone else confirm this problem? That is,
create a treeview with a few nodes, have an afterselect event that opens
another form. Does it open for you?

Does anyone know a work around for this?? Am I doing something really dumb?

Thanks,
Saul
 
Hi all,

Finally, I have found a work around that I can live with. I noted some other
people have had problems like this online, and solved this problem in other
ways. This is an interesting one, but it DID NOT work for me..

http://groups.google.com/groups?q=t...OGDt#[email protected]&rnum=55

So, what did work for me is this : I put a timer on my form and set a
boolean if the treeview was selected. From the timer I check the boolean and
make the call to open the new window if requireed. As it's another object
and event that calls the new window it opens fine without this (re)focus
problem.

This is still not an ideal solution, and you gotta remember to turn off the
timer for performance reasons when you are not using it (I think). However,
it get's me past the problem. I add the solution here in case someone (like
me) does a "google debug" and searches for keywords : Treeview, Show, Hide,
Form, NET etc.

Anyway, hope it helps someone, and if someone can still think of a better
way, I'm all ears.

Regards,
Saul
 
Back
Top