DataGridView.SelectionChanged event fires twice

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

Hi Guys,

Can anyone tell me why the DataGridView.SelectionChanged event fires
twice when I databind to it.

If I do the following, the first row is selected automatically, but the
changed event fires twice:

List<Trailer> trailers = Trailer.SelectAll();

trailerBindingSource.DataSource = trailers;

This is causing a problem because I hide various buttons based on which
row is selected and the multiple event invocation is causing screen
flicker as it executes multiple times

Can anyone help with this?

Many thanks

Simon
 
Hi Guys,

Can anyone tell me why the DataGridView.SelectionChanged event fires
twice when I databind to it.

If I do the following, the first row is selected automatically, but the
changed event fires twice:

List<Trailer> trailers = Trailer.SelectAll();

trailerBindingSource.DataSource = trailers;

This is causing a problem because I hide various buttons based on which
row is selected and the multiple event invocation is causing screen
flicker as it executes multiple times

Can anyone help with this?

Many thanks

Simon

I've seen this before, and I don't know that you can prevent multiple
firings. What is selected each time it fires? Have you looked at
disabling the screen refresh while you bind?
 
Hi there,

Thanks for your reply.

When you say disable screen refresh when databinding occurs, what do you
mean?

Also, which events would it be safe to do this in?

Thanks again for your help

Simon
 
Back
Top