By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,836 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,836 IT Pros & Developers. It's quick & easy.

How to detect datagrid row change

P: n/a
How do i detect a datagrid row change?

Currently, i have a few datagrids that i keep in sync, refreshing from
the database whenver a row changes. I would like to avoid
CurrentCellChanged because changing a cell within the same row causes
an uneccesary DB call. Also, when the row changed to is the "new" row,
nothing should happen.

I wrote some code, which indeed works, but would like to know if i am
missing something more obvious.

When a grid is Fill()ed, it stores count in a variable like
Grid_Row_Count = Data_Set.Tables([table_name]).DefaultView.Count

Private Sub Grid_CurrentCellChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Grid.CurrentCellChanged

Static Current_Row As Integer

If Grid.CurrentRowIndex = Current_Row _
Or Grid.CurrentRowIndex = Grid_Row_Count Then Exit Sub

Current_Row = Grid.CurrentRowIndex

Fill_Child_Grid()

End Sub

B.

Jun 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Brian,

This might work for you:

http://www.syncfusion.com/FAQ/Window...44c.aspx#q823q

Kerry Moorman
"Brian Tkatch" wrote:
How do i detect a datagrid row change?

Currently, i have a few datagrids that i keep in sync, refreshing from
the database whenver a row changes. I would like to avoid
CurrentCellChanged because changing a cell within the same row causes
an uneccesary DB call. Also, when the row changed to is the "new" row,
nothing should happen.

I wrote some code, which indeed works, but would like to know if i am
missing something more obvious.

When a grid is Fill()ed, it stores count in a variable like
Grid_Row_Count = Data_Set.Tables([table_name]).DefaultView.Count

Private Sub Grid_CurrentCellChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Grid.CurrentCellChanged

Static Current_Row As Integer

If Grid.CurrentRowIndex = Current_Row _
Or Grid.CurrentRowIndex = Grid_Row_Count Then Exit Sub

Current_Row = Grid.CurrentRowIndex

Fill_Child_Grid()

End Sub

B.

Jun 26 '06 #2

P: n/a
Kerry Moorman wrote:
Brian,

This might work for you:

http://www.syncfusion.com/FAQ/Window...44c.aspx#q823q

Kerry Moorman
"Brian Tkatch" wrote:
How do i detect a datagrid row change?

Currently, i have a few datagrids that i keep in sync, refreshing from
the database whenver a row changes. I would like to avoid
CurrentCellChanged because changing a cell within the same row causes
an uneccesary DB call. Also, when the row changed to is the "new" row,
nothing should happen.

I wrote some code, which indeed works, but would like to know if i am
missing something more obvious.

When a grid is Fill()ed, it stores count in a variable like
Grid_Row_Count = Data_Set.Tables([table_name]).DefaultView.Count

Private Sub Grid_CurrentCellChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Grid.CurrentCellChanged

Static Current_Row As Integer

If Grid.CurrentRowIndex = Current_Row _
Or Grid.CurrentRowIndex = Grid_Row_Count Then Exit Sub

Current_Row = Grid.CurrentRowIndex

Fill_Child_Grid()

End Sub

B.


Thanx, i appreciate the reply. And that page looks pretty interesting.

Though, that looks a little more complex than what i am doing.

After adding the binding manager, how is it's event triggered?

For the new row, is using a binding manager better than just saving a
class-wide (form)variable holding the number?

The reason i used a variable, is that once the new row is hit, it
automatically increments the datasource's row count, giving me no way
of knowing if it was just added. The code he posted merely checks that
count "((DataTable)dataGrid1.DataSource).Rows.Count; ", how does it know
that the record was not added just then?

B.

Jun 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.