Nasir
Nasir

Reputation: 77

Windows ListView with CheckBoxes

I have a ListView Control in WindowsForm and also this Listivew has a checkBox I Just want one thing that when userClick on CheckBox I want this Event I used ItemCheck and ItemChecked Event but these event is firing every time even when Firstime my form is loading

Upvotes: 0

Views: 743

Answers (2)

xpda
xpda

Reputation: 15813

The Listview control fires itemcheck and itemchecked (and some other) events sometimes at initialization, provided "by design" by Microsoft at no extra charge. You can set a flag (boolean variable) to tell whether the form has completed the loading process, and abort the handler if not.

Upvotes: 0

SLaks
SLaks

Reputation: 887315

Add the following line to the top of your event handler:

if (!this.Visible) return;

Upvotes: 0

Related Questions