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.

deleting child rows in a hierarchical

Thread ID:





13894 May 13,2004 12:28 AM May 13,2004 06:05 AM Windows Forms 2
Tags: GridControl
Asked On May 13, 2004 12:28 AM

Hi I have a old and very important problem in a VB.NET app. I use a GridDataBoundGrid as a hierarchical with 2 tables. Everything works fine instead of child row delete. I can reproduce it in the little project attached... This project was created by you for someone in the forum.... UpdateableExpandGrid_VB_3994.zip So, in this project, you cant add a new child to a row, after deleting all their child... The little cross in the left disappears... How to solve that problem? Just for info, I use Syncfusion 2051. Thanks a lot! bye Syl

Administrator [Syncfusion]
Replied On May 13, 2004 02:47 AM

In the sample I added a InsertChildAtCurrentRow button using the code in the handler below. It seems to work. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cc As GridCurrentCell = Me.gridDataBoundGrid1.CurrentCell Dim rs As GridBoundRecordState = Me.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(cc.RowIndex) ''add a new record to the child level Dim o As Object = rs.ListManager.Current Dim drv As DataRowView = CType(o, DataRowView) Dim dr As DataRow = drv.Row If rs.LevelIndex < 2 Then Dim dt As DataTable = Me.dSet.Tables(rs.LevelIndex + 1) ''get the table Dim newRow As DataRow = dt.NewRow() Dim values As Object() = Nothing Select Case rs.LevelIndex Case 0 Me.numberOfChildren += 1 ''pkValue = this.numberOfChildren; values = New Object() {Me.numberOfChildren, String.Format("ChildName{0}", Me.numberOfChildren), dr(0)} Case 1 Me.numberOfGrandChildren += 1 ''pkValue = this.numberOfGrandChildren; values = New Object() {Me.numberOfGrandChildren, String.Format("GrandChildName{0}", numberOfGrandChildren), dr(0), dt.Columns("FavSport").DefaultValue} Case Else Throw New IndexOutOfRangeException("Improper index") End Select newRow.ItemArray = values dt.Rows.Add(newRow) Dim parentLevel As Integer = rs.LevelIndex - 1 If rs.LevelIndex = 0 Then Me.gridDataBoundGrid1.Model.BeginUpdate() Dim dt1 As DataTable = Me.gridDataBoundGrid1.DataSource Me.gridDataBoundGrid1.DataSource = Nothing Me.gridDataBoundGrid1.DataSource = dt1 Me.gridDataBoundGrid1.EndUpdate() Else Dim row As Integer = cc.RowIndex - 1 If row > Me.gridDataBoundGrid1.Model.Rows.HeaderCount Then Me.gridDataBoundGrid1.Model.BeginUpdate() Me.gridDataBoundGrid1.CollapseAtRowIndex(row) Me.gridDataBoundGrid1.ExpandAtRowIndex(row) Me.gridDataBoundGrid1.CollapseAtRowIndex(row) Me.gridDataBoundGrid1.ExpandAtRowIndex(row) Me.gridDataBoundGrid1.Model.EndUpdate() End If End If End If End Sub

Replied On May 13, 2004 06:05 AM

Magnifique! Thanks a lot Super-Clay After some little update to fit in my project, it''s working fine Thanks again! bye syl


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.

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.