473,394 Members | 1,640 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,394 software developers and data experts.

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.DataGridView.

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.DataGridViewRowsAddedEventAr gs}
Empty: {System.EventArgs}
RowCount: 1
RowIndex: 0

{System.Windows.Forms.DataGridViewRowsAddedEventAr gs}
Empty: {System.EventArgs}
RowCount: 11
RowIndex: 1

{System.Windows.Forms.DataGridViewRowsAddedEventAr gs}
Empty: {System.EventArgs}
RowCount: 1
RowIndex: 0

{System.Windows.Forms.DataGridViewRowsAddedEventAr gs}
Empty: {System.EventArgs}
RowCount: 11
RowIndex: 1
The call stack shows the same line:

Me.SongInfoBindingSource.DataSource = 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 2013
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.DataGridView.

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.DataGridViewRowsAddedEventAr gs}
Empty: {System.EventArgs}
RowCount: 1
RowIndex: 0

{System.Windows.Forms.DataGridViewRowsAddedEventAr gs}
Empty: {System.EventArgs}
RowCount: 11
RowIndex: 1

{System.Windows.Forms.DataGridViewRowsAddedEventAr gs}
Empty: {System.EventArgs}
RowCount: 1
RowIndex: 0

{System.Windows.Forms.DataGridViewRowsAddedEventAr gs}
Empty: {System.EventArgs}
RowCount: 11
RowIndex: 1
The call stack shows the same line:

Me.SongInfoBindingSource.DataSource = 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
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,...
6
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...
0
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...
1
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...
1
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...
2
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...
7
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...
7
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.