473,839 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGridView.Se lectionChanged event fires twice

Hi Guys,

Can anyone tell me why the DataGridView.Se lectionChanged 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<Trailertra ilers = Trailer.SelectA ll();

trailerBindingS ource.DataSourc e = 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 9701
On Mar 20, 7:09 am, Simon Harvey <notha...@hotma il.comwrote:
Hi Guys,

Can anyone tell me why the DataGridView.Se lectionChanged 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<Trailertra ilers = Trailer.SelectA ll();

trailerBindingS ource.DataSourc e = 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
5015
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 (using Full Row Select), but this event is trigger only after the selection changed is completed and therefore is non cancelable unless you keep the previous selection in a variable and rechange the selection, which is painful.
0
1307
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 datagrid to have nothing selected by default, until a row is selected by the user. Is this possible?
0
1310
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 little or no help on this -- unbelievable if true! For example, the RowValidating event -- does it occur when the row changes, or when the cell in a row changes? (My experiments with this seem to indicate that it first when the cell changes, even...
0
1519
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 SelectionChanged event. When I load the data, I set the DataSource property, and then call ClearSelection() to make sure there are no selected rows.
7
16499
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 they can only input numerical values. Is there any way to do this? Currently my formatting works but if the user enters a value manually the formatting is not applied to the new value. Also I haven't found a way to allow only numerical input....
0
2167
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 is immediately below the Top Left Corner Select All cell. When clicking on the Top Left Corner SelectAll cell, which selects all the Rows/columns in the datagridview, the only event that appears to fire is the SelectionChanged event. But that...
0
2976
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 the filter is set i get an IndexOutOfRangeException specifying that the index of the row i have just added does not exist. I have managed to narrow down the conditions that cause the error and it seems to surface if i have a filter set for a...
6
8812
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, 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
2
8459
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 click on appropriate row of the datagridview.Grid has only one event "cellcontentclick" is displayed.But i want to use "cellclick" or "selectionchanged" event of datagridview. So plz help me...How to do this....? Thax in advance.......
0
9856
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10910
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10589
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10297
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9426
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7021
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5683
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.