Form2 shows with Form1's title and menu

L

Lei Gong

I have 2 forms, form1 contains a ListView. What I want to do is, when
clicking an item in the ListView, hide form1 and show form2. Code for
ListView's SelectedIndexChanged: { form2.Show(); this.Hide(); }. When I
click the item, form2 shows with form1's title and menu. I noticed that when
mouse down, the SelectedIndexChanged event was triggered and bring form2 to
front. But when mouse up, system redrawed the selected item and bring title
and menu back to form1's. I tried to handle MouseDown and MouseUp event of
ListView but they were never triggered. Now I used a tricky way to solve the
problem: start a thread and use Control.Invoke to switch forms. It is not
good, I think there must be a better solution. Thanks.
 
S

Saul Bryan

Lei,

Opening a form directly in the ListView's SelectedIndexChanged event just
doesn't work. I came across this problem myself, and it's a frustrating one.
I call it a bug myself. You can see my thread about it here, including what
I came across as a fix.

http://groups.google.com.au/groups?...c30e37c6%40lon-reader.news.telstra.net&rnum=3

(I hope that works for you, it may or may not).

In summary, what I did is start a timer, which checks a global boolean. If
this is true, it opens form2 and stops the timer. The ListView's
SelectedIndexChanged simply sets this boolean to true.

Regards,
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