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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

deleting in the hierarchical

Thread ID:

Created:

Updated:

Platform:

Replies:

13350 Apr 27,2004 09:57 AM UTC Apr 27,2004 09:27 PM UTC Windows Forms 1
loading
Tags: GridControl
Syl
Asked On April 27, 2004 09:57 AM UTC

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

Administrator [Syncfusion]
Replied On 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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;