471,627 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

C# ListView question

Hi,

In my C# Windows Form MyForm, it has a ListView ListView1.
If I click those ListViewItems in ListView1, it's OK; but if I click empty
space in ListView1 rather than those ListViewItems, then there will come
errors.
How do I fix this problem?
Thanks for help.
Jason
Jan 27 '06 #1
3 2638
You should provide some more details of which event you're handling, what
you're doing in that event handler that is throwing exceptions and what those
exceptions are.

A quick guess on my part is that you may be handling the Click event and
then, in your code, trying to do something with SelectedItems. If you
clicked an empty area of the ListView then SelectedItems would be empty. The
solution would be to verify that SelectedItems.Count is not 0 before doing
anything with SelectedItems in your event handler.

HTH
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Jason Huang" wrote:
Hi,

In my C# Windows Form MyForm, it has a ListView ListView1.
If I click those ListViewItems in ListView1, it's OK; but if I click empty
space in ListView1 rather than those ListViewItems, then there will come
errors.
How do I fix this problem?
Thanks for help.
Jason

Jan 27 '06 #2
Hi,

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
Hi,

In my C# Windows Form MyForm, it has a ListView ListView1.
If I click those ListViewItems in ListView1, it's OK; but if I click empty
space in ListView1 rather than those ListViewItems, then there will come
errors.
How do I fix this problem?

What error?
Post the code of the handler or at least the description of the exception
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 27 '06 #3
?
"Jason Huang" <Ja************@hotmail.com> glsD:uL**************@TK2MSFTNGP10.phx.g bl...
Hi,

In my C# Windows Form MyForm, it has a ListView ListView1.
If I click those ListViewItems in ListView1, it's OK; but if I click empty
space in ListView1 rather than those ListViewItems, then there will come
errors.
How do I fix this problem?
Thanks for help.
Jason

Feb 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by J_Max | last post: by
7 posts views Thread by Dave Y | last post: by
3 posts views Thread by MikeY | last post: by
1 post views Thread by Derck | last post: by
12 posts views Thread by J L | last post: by
1 post views Thread by Chris | last post: by
12 posts views Thread by garyusenet | last post: by
1 post views Thread by =?Utf-8?B?THluYkBtcy5jb20=?= | last post: by
5 posts views Thread by Mark Olbert | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.