DataGridView.SelectionChanged event fires twice

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
 
C

cokert

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?
 
S

Simon Harvey

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top