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

Best way of detecting if a row has been added to dataGrid

Hello,
Can someone tell me what is the best way of implementing the detection of
adding a row to a datagrid. I looked at using a DataView as the datasource
and the ListChanged event, but that didn't seem to work like I expected. It
seemed to fire only when I changed to another row in the grid, not when I
clicked on the little pencil icon on the left margin of the grid. Is the
ListChanged suppose to be used for this? If so, how?
Thanks for any help
Cheers :)
Nov 15 '05 #1
2 1536
Randy,

Well, I can definitely see why this is. When you click on the little
pencil icon on the right, the grid shows the UI for a new record, but it
hasn't tried to add one yet. Not until you move off the row can the record
be added to the underlying data source. If you want to figure out when the
little pencil is clicked (a new record is added) then, I would handle the
MouseDown event and then pass the coordinates to the HitTest method to
determine where the grid was clicked. If it was the row headers, then you
can check which row, and then see if the row is a new row, and then perform
the appropriate action.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Randy" <None> wrote in message
news:Oj**************@TK2MSFTNGP09.phx.gbl...
Hello,
Can someone tell me what is the best way of implementing the detection of
adding a row to a datagrid. I looked at using a DataView as the datasource
and the ListChanged event, but that didn't seem to work like I expected. It seemed to fire only when I changed to another row in the grid, not when I
clicked on the little pencil icon on the left margin of the grid. Is the
ListChanged suppose to be used for this? If so, how?
Thanks for any help
Cheers :)

Nov 15 '05 #2
Yes, that definitely puts me in the right direction. Thanks for the help!

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Op*************@tk2msftngp13.phx.gbl...
Randy,

Well, I can definitely see why this is. When you click on the little
pencil icon on the right, the grid shows the UI for a new record, but it
hasn't tried to add one yet. Not until you move off the row can the record be added to the underlying data source. If you want to figure out when the little pencil is clicked (a new record is added) then, I would handle the
MouseDown event and then pass the coordinates to the HitTest method to
determine where the grid was clicked. If it was the row headers, then you
can check which row, and then see if the row is a new row, and then perform the appropriate action.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Randy" <None> wrote in message
news:Oj**************@TK2MSFTNGP09.phx.gbl...
Hello,
Can someone tell me what is the best way of implementing the detection of adding a row to a datagrid. I looked at using a DataView as the datasource and the ListChanged event, but that didn't seem to work like I expected.

It
seemed to fire only when I changed to another row in the grid, not when I clicked on the little pencil icon on the left margin of the grid. Is the
ListChanged suppose to be used for this? If so, how?
Thanks for any help
Cheers :)


Nov 15 '05 #3

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

Similar topics

4
by: Sam Smith | last post by:
I am using optparse for the commandline parsing for my programs. I was wondering if it is possible to detect if an option or option-arg has been specified on the commandline by the user or not....
1
by: Alex | last post by:
Hi all... I have a DataGrid bound to a DataTable. My DataTable gets updated programmatically as it contains the status of a number of worker threads. Each "main" worker thread launches a...
3
by: Randy | last post by:
Hello, How would one go about detecting which row/column was clicked in a datagrid. I'm sure it can be done but I can't figure it out. Thanks
0
by: RA | last post by:
Hi I am getting the DataGrid row click event. My question is how can I get the DataTable that is corresponding to the DataGrid row. This is not one to one relationship because the DataGrid might...
3
by: WebMatrix | last post by:
I am struggling with implementing somewhat complicated UI web-control. I explored Repeater, but I am not sure if it's the best way to go. I am leaning towards writing my own custom control and...
7
by: Wayne Wengert | last post by:
I am using VB with a Windows NET application. I have a datagrid in which the user can add rows using the "*" row. I want to detect whenever the user has added a row. I found the following code at...
4
by: Dave | last post by:
(My apologies for posting this on two forums. I have just found out the other one was the incorrect location) I am writing a VB.NET 2003 web application to operate on my company's intranet. It...
1
by: Jeff User | last post by:
Hello all I need to build a web form that will allow user to enter database table column definitions. Each row on the form would contain column name, data type (chosen from a drop down list), size...
3
by: Greg | last post by:
The LostFocus event of datagrids is fired when the focus is added to a cell. How do you go about detecting it when the control as a whole has lost focus to another control? Slightly confused by...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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,...

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.