|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to detect datagrid row changeCurrently, 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. Brian,
This might work for you: http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q823q Kerry Moorman Show quoteHide quote "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. > > Kerry Moorman wrote:
Show quoteHide quote > Brian, Thanx, i appreciate the reply. And that page looks pretty interesting.> > This might work for you: > > http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.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. > > > > 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.
ASP.NET web application - date conversions UK date format?
Building a single EXE file in VB 2005? What errors are not trappable? default in .NET byref or byval? Build Failed - 0 Errors Adding ActiveX controls at runtime and threading DataGridView row background color How to gain access to objet in different class ? Define a compilation switch Listbox help |
|||||||||||||||||||||||