473,763 Members | 4,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to understand the DataGridView

I am trying to find the event (if there is one) which occurs when a row
is added to the DataGridView.

The closest I can find is the RowsAdded event which says in documentation:

Occurs after a new row is added to the System.Windows. Forms.DataGridV iew.

OK then so I debug my code. I am adding 11 rows with a datasource and I
get 4 occurences of the RowsAdded:

?e
{System.Windows .Forms.DataGrid ViewRowsAddedEv entArgs}
Empty: {System.EventAr gs}
RowCount: 1
RowIndex: 0

{System.Windows .Forms.DataGrid ViewRowsAddedEv entArgs}
Empty: {System.EventAr gs}
RowCount: 11
RowIndex: 1

{System.Windows .Forms.DataGrid ViewRowsAddedEv entArgs}
Empty: {System.EventAr gs}
RowCount: 1
RowIndex: 0

{System.Windows .Forms.DataGrid ViewRowsAddedEv entArgs}
Empty: {System.EventAr gs}
RowCount: 11
RowIndex: 1
The call stack shows the same line:

Me.SongInfoBind ingSource.DataS ource = newSource

for each event occurrence and the above line is executed only once.
This is somewhat confusing as it does not do as the documentation says
and even so why is it doing the event four times and why oh why can the
DataGridView not have events like in ASP.NET so that on each addition of
a row it will give you an event so that you can do whatever is needed at
that time?????

Lloyd Sheen
Aug 20 '08 #1
2 2046
I would use a datasource table for the datagridview. The dataTable
object is much easier to manage for adding/deleting/updating rows.
Everything you do to the underlying dataTable gets displayed instantly
on the datagridview

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 21 '08 #2
I repro the problem here. If you handle also RowsDeleted you'll better
understand what's going on.

Not familiar yet with this but this is where
http://referencesource.microsoft.com/ could be usefull...

For now it looks like rows are added then removed several times ??? I
thought ti could be related to sortable columns but apparently not...

--
Patrice

"Lloyd Sheen" <a@b.ca écrit dans le message de groupe de discussion :
ev************* *@TK2MSFTNGP04. phx.gbl...
I am trying to find the event (if there is one) which occurs when a row is
added to the DataGridView.

The closest I can find is the RowsAdded event which says in documentation:

Occurs after a new row is added to the System.Windows. Forms.DataGridV iew.

OK then so I debug my code. I am adding 11 rows with a datasource and I
get 4 occurences of the RowsAdded:

?e
{System.Windows .Forms.DataGrid ViewRowsAddedEv entArgs}
Empty: {System.EventAr gs}
RowCount: 1
RowIndex: 0

{System.Windows .Forms.DataGrid ViewRowsAddedEv entArgs}
Empty: {System.EventAr gs}
RowCount: 11
RowIndex: 1

{System.Windows .Forms.DataGrid ViewRowsAddedEv entArgs}
Empty: {System.EventAr gs}
RowCount: 1
RowIndex: 0

{System.Windows .Forms.DataGrid ViewRowsAddedEv entArgs}
Empty: {System.EventAr gs}
RowCount: 11
RowIndex: 1
The call stack shows the same line:

Me.SongInfoBind ingSource.DataS ource = newSource

for each event occurrence and the above line is executed only once. This
is somewhat confusing as it does not do as the documentation says and even
so why is it doing the event four times and why oh why can the
DataGridView not have events like in ASP.NET so that on each addition of a
row it will give you an event so that you can do whatever is needed at
that time?????

Lloyd Sheen

Aug 21 '08 #3

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

Similar topics

0
3623
by: DraguVaso | last post by:
Hi, I'm using the DataGridView in VB.NET 2.0. The DataSource is a Generic List of a custom class0: lstMyPersonnes = New List(Of clsPersonne). When I add a new clsPersonne to lstMyPersonnes, and rebind the lstMyPersonnes to my DataGridView.dataSource, it shows the new record in the DataGridView as it should be. But when I click on a cell of that row, I suddenly got this error: "Index -1
6
6415
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I gave it a try using the example given in
0
2088
by: Martin Widmer | last post by:
Hello again! I have a datagridview control on my form and am using VS.Net 2005. One column is set up as combo box column, and when I try to set the datasource for that combobox column at design time in the properties section of VS, I get the error "object reference not set to instance of an object" and the only option is to click OK. I have not yet tried to set that datasource at runtime, but of course I could do that. But I don't...
1
18885
by: Dave A | last post by:
Hi, I am struggling with two way databinding in WinForms and the DataGridView. I am binding to business object classes (rather than datatables). If I have a collection of these business objects that is the datasource of a DataBinding that is bound to a DataGridView (WinForms) then I was expecting that any change to the data would be reflected in the DataGridView (in other words I was expecting the 2 way databinding to actually...
1
1747
by: Bruce HS | last post by:
I'm using VS2005, VB, WinForms I’ve developed forms using those nice wizards Microsoft provides. However, I’m running into a couple of complications trying to work with the resulting Table Adapters. 1) My user interface allows the user to fill in any combination of perhaps a dozen Query-By-Example (QBE) fields, and then press a Query button to generate a list, based on an SQL statement that incorporates those QBE fields. The...
2
24558
by: bob | last post by:
Can anyone tell me the best way to update a dataset while it is being edited/viewed in the DataGridView control? Is this something that should be inserted into one of the grid's events? or should you update after closing the grid/form, etc.? Also, can you tell me the best book to buy that fully explains the DataGridView control? Thanks.
7
12631
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's the background for my question... Before I switched my application over to the Fx 2.0, I used a DataGrid to display my data. I would store different DataGridTableStyles (each one with a custom set of columns) in the DataGrid.TableStyles property...
7
15658
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is there an equivalent property for the DataGridView? I have searched, but have not found one. I would like the user to be able to see all the columns of the table on one screen - thus eliminating the need to use the horizontal scroll bar to view...
3
5742
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows few celltemplate property getters and combobox/datecombo constructor calls without database access which does not take a lot of time. Debug output (below) shows lot of messages Stepping over non-user code. Running in release mode from...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
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
9997
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...
1
9937
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
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
5270
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...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.