468,248 Members | 1,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,248 developers. It's quick & easy.

Form Not Respond To Mouse Click

I have an msn style c# windows application with a form and panel on
it.
A news list is drawn from the database and dynamically added via
labels, link lables during form loading. In this application at run
time this list should be generated again as the filtering criteria
changes. So I clear the controls(labels) on the panel, get the list
from the database and generate the list again. The list is created
and
it works fine. But sometimes the form begins not to respond to mouse
clicks. Only mouse over and mousemove events work. Does anybody have
suggestions on why this happens?

Feb 22 '07 #1
5 2005
A mouse click is handled by a Control, not by the Form, unless there is no
Control in the location of the mouse click. If the Control does not have the
focus, the first mouse click will focus on the Control, and the second will
cause the Click event.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.

"moonie" <se************@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
>I have an msn style c# windows application with a form and panel on
it.
A news list is drawn from the database and dynamically added via
labels, link lables during form loading. In this application at run
time this list should be generated again as the filtering criteria
changes. So I clear the controls(labels) on the panel, get the list
from the database and generate the list again. The list is created
and
it works fine. But sometimes the form begins not to respond to mouse
clicks. Only mouse over and mousemove events work. Does anybody have
suggestions on why this happens?

Feb 22 '07 #2
Thanks for your answer Kevin.
But I did not understand what should I do to fix the problem :)
I placed this.Refresh();this.Activate(); in the form code but it
did'nt help.
Also I should inform you that there are three panels on the form and
the labels, buttons etc. are on these panels.

On 22 ubat, 15:55, "Kevin Spencer" <unclechut...@nothinks.comwrote:
A mouse click is handled by a Control, not by the Form, unless there is no
Control in the location of the mouse click. If the Control does not have the
focus, the first mouse click will focus on the Control, and the second will
cause the Click event.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.

"moonie" <serafettina...@gmail.comwrote in message

news:11**********************@q2g2000cwa.googlegro ups.com...
I have an msn style c# windows application with a form and panel on
it.
A news list is drawn from the database and dynamically added via
labels, link lables during form loading. In this application at run
time this list should be generated again as the filtering criteria
changes. So I clear the controls(labels) on the panel, get the list
from the database and generate the list again. The list is created
and
it works fine. But sometimes the form begins not to respond to mouse
clicks. Only mouse over and mousemove events work. Does anybody have
suggestions on why this happens?- Alnty gizle -

- Alnty gster -

Feb 22 '07 #3
I found the solution :) I called Panel.Controls.Clear() method to
remove the labels and links. That is why the controls were not
disposed and their event handlers were not removed. So when I added
new controls with same event handlers somehow it got confused and the
click event did not work. Now I call Panel.Control[i].Dispose() for
every control on the panel and add new controls and it works great!

On 22 Şubat, 16:21, "moonie" <serafettina...@gmail.comwrote:
Thanks for your answer Kevin.
But I did not understand what should I do to fix the problem :)
I placed this.Refresh();this.Activate(); in the form code but it
did'nt help.
Also I should inform you that there are three panels on the form and
the labels, buttons etc. are on these panels.

On 22 Þubat, 15:55, "Kevin Spencer" <unclechut...@nothinks.comwrote:
A mouse click is handled by a Control, not by the Form, unless there isno
Control in the location of the mouse click. If the Control does not have the
focus, the first mouse click will focus on the Control, and the second will
cause the Click event.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com
I had the same problem once. Fixed it using the same solution.
"moonie" <serafettina...@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
>I have an msn style c# windows application with a form and panel on
it.
A news list is drawn from the database and dynamically added via
labels, link lables during form loading. In this application at run
time this list should be generated again as the filtering criteria
changes. So I clear the controls(labels) on the panel, get the list
from the database and generate the list again. The list is created
and
it works fine. But sometimes the form begins not to respond to mouse
clicks. Only mouse over and mousemove events work. Does anybody have
suggestions on why this happens?- Alýntýyý gizle -
- Alýntýyý göster -- Alıntıyı gizle -

- Alıntıyı göster -

Feb 23 '07 #4
I found the solution :) I called Panel.Controls.Clear() method to
remove the labels and links. That is why the controls were not
disposed and their event handlers were not removed. So when I added
new controls with same event handlers somehow it got confused and the
click event did not work. Now I call Panel.Control[i].Dispose() for
every control on the panel and add new controls and it works great!

On 22 Şubat, 16:21, "moonie" <serafettina...@gmail.comwrote:
Thanks for your answer Kevin.
But I did not understand what should I do to fix the problem :)
I placed this.Refresh();this.Activate(); in the form code but it
did'nt help.
Also I should inform you that there are three panels on the form and
the labels, buttons etc. are on these panels.

On 22 Þubat, 15:55, "Kevin Spencer" <unclechut...@nothinks.comwrote:
A mouse click is handled by a Control, not by the Form, unless there isno
Control in the location of the mouse click. If the Control does not have the
focus, the first mouse click will focus on the Control, and the second will
cause the Click event.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com
I had the same problem once. Fixed it using the same solution.
"moonie" <serafettina...@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
>I have an msn style c# windows application with a form and panel on
it.
A news list is drawn from the database and dynamically added via
labels, link lables during form loading. In this application at run
time this list should be generated again as the filtering criteria
changes. So I clear the controls(labels) on the panel, get the list
from the database and generate the list again. The list is created
and
it works fine. But sometimes the form begins not to respond to mouse
clicks. Only mouse over and mousemove events work. Does anybody have
suggestions on why this happens?- Alýntýyý gizle -
- Alýntýyý göster -- Alıntıyı gizle -

- Alıntıyı göster -

Feb 23 '07 #5
Good work, moonie. Yes, it is important to dispose of any Controls that are
added to another Control.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.

"moonie" <se************@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
I found the solution :) I called Panel.Controls.Clear() method to
remove the labels and links. That is why the controls were not
disposed and their event handlers were not removed. So when I added
new controls with same event handlers somehow it got confused and the
click event did not work. Now I call Panel.Control[i].Dispose() for
every control on the panel and add new controls and it works great!

On 22 Subat, 16:21, "moonie" <serafettina...@gmail.comwrote:
Thanks for your answer Kevin.
But I did not understand what should I do to fix the problem :)
I placed this.Refresh();this.Activate(); in the form code but it
did'nt help.
Also I should inform you that there are three panels on the form and
the labels, buttons etc. are on these panels.

On 22 ubat, 15:55, "Kevin Spencer" <unclechut...@nothinks.comwrote:
A mouse click is handled by a Control, not by the Form, unless there is
no
Control in the location of the mouse click. If the Control does not have
the
focus, the first mouse click will focus on the Control, and the second
will
cause the Click event.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composerhttp://unclechutney.blogspot.com
I had the same problem once. Fixed it using the same solution.
"moonie" <serafettina...@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
>I have an msn style c# windows application with a form and panel on
it.
A news list is drawn from the database and dynamically added via
labels, link lables during form loading. In this application at run
time this list should be generated again as the filtering criteria
changes. So I clear the controls(labels) on the panel, get the list
from the database and generate the list again. The list is created
and
it works fine. But sometimes the form begins not to respond to mouse
clicks. Only mouse over and mousemove events work. Does anybody have
suggestions on why this happens?- Alnty gizle -
- Alnty gster -- Alintiyi gizle -

- Alintiyi gster -


Feb 23 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Thomas W Ping | last post: by
6 posts views Thread by lauren quantrell | last post: by
1 post views Thread by Lloyd Sheen | last post: by
reply views Thread by moonie | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.