0

I've got a ListView which is normally hidden and Enabled=false;
I'm using the ItemChecked event Enable/Disable a button on the form (the button is disabled if nothing is checked)

If I add the ItemChecked event handler via the Designer in the usual way, it puts the code in the usual place and then when I enable the ListView it locks my app into an (apprently) infinite loop.
However, if I move the event handler assignment to a point AFTER the control is enabled, it works as expected.

I was just wondering if anyone can explain this behaviour... why is enabling a control with no checked items firing the ItemChecked event?

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Mitja Bonca
0

Put some boolean flag into the code, so you can say to the code when it can be used and when not - but you.

I mean something like:

bool bFlag = false;

void buttonEnable()//event of button
{
    bFlag = true;  // this will prevent firing the ItemChecked code in the 1st go-through
}

void ItemChecked() //event of listView
{
   if(!bflag)
   {
       // put yout code in this even in here...
   }
   else
       bFlag = false;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.