A
anonymous.user0
I know that by design, the SelectedIndexChanged event fires twice when
the SelectedIndex changes, once for the unselection of the previous
index, and once for the selection of the new index. This is somewhat
bothersome to me because I have listeners for those events that toggle
the enabled states of other controls on the form based on whether an
item is selected or not, and this creates an ugly blinking effect.
Is there any way to peek into the message queue and see if there is
another SelectedIndexChange event coming? I know I can't see into the
future, but I'm hoping the messages will be placed into the queue
simultaniously and that they will both be in the queue when I recieve
the first event.
My current solution, which I'm not really that pleased with, is to have
a Timer t on the form with a 100 millisecond interval. When the
SelectedIndexChanged event fires, I check a flag to see if the timer is
running. If it's not running, I start the timer and set the flag. On
the Tick event of the timer, I fire my own SelectedItemChanged event,
stop the timer, and reset the flag.
Basically what's happening is I'm only allowing one SelectedIndex event
to fire within any given 100 millisecond window.
This works, I don't get the flickering, but it seems kinda hackish and
unpredicable.
Any better suggestions?
the SelectedIndex changes, once for the unselection of the previous
index, and once for the selection of the new index. This is somewhat
bothersome to me because I have listeners for those events that toggle
the enabled states of other controls on the form based on whether an
item is selected or not, and this creates an ugly blinking effect.
Is there any way to peek into the message queue and see if there is
another SelectedIndexChange event coming? I know I can't see into the
future, but I'm hoping the messages will be placed into the queue
simultaniously and that they will both be in the queue when I recieve
the first event.
My current solution, which I'm not really that pleased with, is to have
a Timer t on the form with a 100 millisecond interval. When the
SelectedIndexChanged event fires, I check a flag to see if the timer is
running. If it's not running, I start the timer and set the flag. On
the Tick event of the timer, I fire my own SelectedItemChanged event,
stop the timer, and reset the flag.
Basically what's happening is I'm only allowing one SelectedIndex event
to fire within any given 100 millisecond window.
This works, I don't get the flickering, but it seems kinda hackish and
unpredicable.
Any better suggestions?