473,394 Members | 1,709 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.

Is there an OnChange() for DataGridView when the DataSource is changed?

110 100+
I know there is an Overridable OnDataSourceChanged() subroutine, but I am looking for an event handler which is ran every time I add/remove an element from the collection I set within the DataSource.

It doesn't seem like this event handler does that. Or if it does, I also need the event come after the grid shows the new row, so I can set the cells that I desire to readonly or non-readonly.

I'm at work, so I may post some example code later tonight if I have time (working over 80 hours a week is tough :)

Hopefully Helpful,

TamusJRoyce
Nov 13 '08 #1
3 7354
Plater
7,872 Expert 4TB
OnDataSourceChanged is a Property change event, it fires when when you call myThing.Datasource = Something

You might be able to get something from the RowsAdded event or UserAddedRow or maybe even DefaultValuesNeeded(I heard somewhere that gets called)
Nov 13 '08 #2
TamusJRoyce
110 100+
I've meant to reply back on this, but haven't been home to have time to do that.

Just wanted to say thanks for your reply. I've tried that, but it doesn't work for what I need it to be able to do.

To solve my problem, I simply called a subroutine from each writable property in my class. Then inside the subroutine I deal with the things I need to. Given was quite expensive writing, it worked.

I would still like a way to catch every change that occurs in each record in my dataviewgrid. And through debugging, I've realized I really dislike it constantly using the getters of my function to set the data, rather than have the bindinglist/DataBoundItem fire an event to the datagrid view.

Such things are very inefficient.

Hopefully Helpful,

TamusJRoyce
Nov 24 '08 #3
mldisibio
190 Expert 100+
Like you, a bit short on time for elaborate examples, but have a look at: INotifyPropertyChanged Interface.
The type represented by the bound items would implement this interface.

The INotifyPropertyChanged interface is used to notify clients, typically binding clients, that a property value has changed.
...you will notice the bound DataGridView control reflects the change in the data source without requiring the binding to be reset.
Nov 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
0
by: Pieter Coucke | last post by:
Hi, I have a DataGridView, that contains a list of Articles, which can be added (automaticly via the AllowUserToAddRows) and changed by the user. The current item is also displayed in textboxes...
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...
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
5
by: DanThMan | last post by:
The situation: * I have a ButtonColumn in a DataGridView. * When the user preses one of the buttons, a dialog appears. * Based on what the user selects in the dialog, data is entered...
4
by: Terry Olsen | last post by:
How can i tell if a row in my DataGridView has been edited? I'm loading a DataTable with ID3 information from MP3 files and using that as the datasource for the DataGridView. I'm letting the user...
9
by: trint | last post by:
How can I retrieve all of the data from a datagridview? Any help is appreciated. Thanks, Trint
6
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab...
1
by: Avedo | last post by:
Hello! I have a form application with a DataGridView, and an Save/Delete and Cancel button. When the application is opened, it is supplied an XML file that may or may not exist, and display the...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...

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.