We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

deleting in the hierarchical

Hi I use a hierarchical (gridDataBoundGrid) with 2 tables... I can add and delete childs.... When I delete all the childs, the cross (at the start of the parent line) disappear..... after I cant add a new child row.... So... Why I am not able to add new row? Is there a state for a row to enable adding new childs? Can i activated in the code? Here is some code I use : -- add a child row Public Sub AddChild() Dim cc As GridCurrentCell = dgbg.CurrentCell Dim rs As GridBoundRecordState = dgbg.Binder.GetRecordStateAtRowIndex(cc.RowIndex) ''add a new record to the same level If rs.ListManager.Position >= 0 Then Dim dr As DataRow = CType(rs.ListManager.Current, DataRowView).Row Dim dt As DataTable = Me._dataset.Tables(1) Dim newRow As DataRow = dt.NewRow() Dim values As Object() = Nothing values = GetNewValues() newRow.ItemArray = values dt.Rows.Add(newRow) RefreshCurrentParentNode() End If End Sub -- delete a row : Public Sub DeleteCurrentChildOrParent() Dim dt As DataTable = Me._dataset.Tables(0) Dim cc As GridCurrentCell = Me.dgbg.CurrentCell Dim row As Integer = cc.RowIndex Dim col As Integer = cc.ColIndex Dim rs As GridBoundRecordState = dgbg.Binder.GetRecordStateAtRowIndex(cc.RowIndex) ''remove the current record Dim i As Integer = rs.Position rs.ListManager.Position = i - 1 Try rs.ListManager.RemoveAt(i) RefreshCurrentParentNode() If row >= Me.dgbg.Model.RowCount Then row = row - 1 End If Me.dgbg.CurrentCell.MoveTo(row, col) Catch ex As Exception End Try End Sub --the refresh methode : Private Sub RefreshCurrentParentNode() Dim cc As GridCurrentCell = dgbg.CurrentCell Dim rs As GridBoundRecordState = dgbg.Binder.GetRecordStateAtRowIndex(cc.RowIndex) Select Case rs.LevelIndex Case 0 Me.dgbg.CollapseAtRowIndex(cc.RowIndex) Me.dgbg.ExpandAtRowIndex(cc.RowIndex) Case 1 Dim parentLevel As Integer = 0 Dim row As Integer = cc.RowIndex - 1 While row > Me.dgbg.Model.Rows.HeaderCount rs=dgbg.Binder.GetRecordStateAtRowIndex(row) If rs.LevelIndex = parentLevel Then Exit While End If row -= 1 End While Me.dgbg.CollapseAtRowIndex(row) Me.dgbg.ExpandAtRowIndex(row) End Select End Sub Thanks for your help! bye syl

1 Reply

AD Administrator Syncfusion Team April 27, 2004 09:27 PM UTC

If you are using the 2.0 code base, you might try setting grid.OptimizeListChangedEvent to see if that will allow this to work.

Loader.
Live Chat Icon For mobile
Up arrow icon