473,395 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DataGridView.SelectionChanged event fires twice

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<Trailertrailers = 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
Mar 20 '07 #1
2 9626
On Mar 20, 7:09 am, Simon Harvey <notha...@hotmail.comwrote:
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<Trailertrailers = 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?

Mar 20 '07 #2
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
Mar 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michel Lapointe | last post by:
Hello, I would like to know if there is an event for the Datagridview control that is trigger before the selection change and is cancelable. I'm currently using the SelectionChanged event...
0
by: Paul Cheetham | last post by:
Hi, I have a DataGridView Control, which I am databinding at run-time. When the data is loaded, the first row in the grid gets selected, and the selectionChanged event gets fired. I want the...
0
by: bob | last post by:
Hi all, I'm having a hard time figuring out the ORDER that the events in the DataGridView control fire in, and also determining exactly WHEN each event fires. The documentation seems to have...
0
by: Paul Cheetham | last post by:
Hi, I have a DataGridView control, where I am setting its Datasource property to a datatable. The DataGridView has it's MultiSelect property set to false I also have a handler for the...
7
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
In a datagridview, the first column header cell is columnHeader(0), which is immediately to the right of the Top Left Corner Select All cell. And the first RowHeader cell is RowHeaderCell(0) which...
0
by: =?Utf-8?B?aW1yYW4uYQ==?= | last post by:
Hi all, I am having a problem with inserting rows in to my datagridview control. The datagridview is bound to a bindingsource with a filter set. If i try and add a row to the datagridview while...
6
by: Simon Harvey | last post by:
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,...
2
by: hnpatel | last post by:
Hi to All, How to use mouse click event for datagridview in c# in vs2005? I m using datagridview in c# application.I had bound data in datagridview.I want to display data in textbox when i...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.