S
Simon Harvey
Hi all,
I'm really hoping someone can help me with this as it's causing me some
serious problems.
I have a Windows Forms application using the gridview control. When the
user selects a row, the SelectionChanged event fires and I load some
more data that's particular to that row.
The problem I'm having is that the SelectionChanged event is going way
to many times and this is obviously causing me to load the additional
data scores of times when it's not necessary.
The sorts of things that are causing it to occur are:-
- Refreshing the data
- Calling ClearSelection
- Calling Sort
I can certainly understand why these actions would cause the
SelectionChanged event to fire, but the problem is the sheer number of
times it fires. For example for some reason, when I refresh the binding
source's data, it will fire say, 5 times. Then if I do it again, it will
become 10 times even though I'm clearing the data and not adding to it.
Similarly, when I call sort it seems to cause SelectionChanged to fire
once for each row.
I've tried all sorts of things like detaching event handlers and then
reattaching them after performing a key action but this only helps a
little. Sometimes detaching the event handler doesn't seem to do
anything - the event still fires!
Can anyone help me with some strategy for dealing with this. I'd be
really surprised if I were the only person that was experiencing this so
I'm hoping someone will be able to help me.
Sincerest thanks to anyone who can advise
Best Regards
Simon
I'm really hoping someone can help me with this as it's causing me some
serious problems.
I have a Windows Forms application using the gridview control. When the
user selects a row, the SelectionChanged event fires and I load some
more data that's particular to that row.
The problem I'm having is that the SelectionChanged event is going way
to many times and this is obviously causing me to load the additional
data scores of times when it's not necessary.
The sorts of things that are causing it to occur are:-
- Refreshing the data
- Calling ClearSelection
- Calling Sort
I can certainly understand why these actions would cause the
SelectionChanged event to fire, but the problem is the sheer number of
times it fires. For example for some reason, when I refresh the binding
source's data, it will fire say, 5 times. Then if I do it again, it will
become 10 times even though I'm clearing the data and not adding to it.
Similarly, when I call sort it seems to cause SelectionChanged to fire
once for each row.
I've tried all sorts of things like detaching event handlers and then
reattaching them after performing a key action but this only helps a
little. Sometimes detaching the event handler doesn't seem to do
anything - the event still fires!
Can anyone help me with some strategy for dealing with this. I'd be
really surprised if I were the only person that was experiencing this so
I'm hoping someone will be able to help me.
Sincerest thanks to anyone who can advise
Best Regards
Simon