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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hierarchical GDBG - deleting child rows

Thread ID:





15390 Jun 17,2004 01:48 AM UTC Jun 17,2004 03:59 PM UTC WinForms 5
Tags: GridControl
Lori S. Pearsall
Asked On June 17, 2004 01:48 AM UTC

Version I execute the following code to delete child records : GridBoundRecordState rs = null; CurrencyManager cm = null; this.BeginUpdate(); for ( int i = bookmarks.Length - 1; i >= 0; i-- ) { rs = this.Binder.GetRecordStateAtRowIndex(bookmarks[i]); if (rsType == RowSelectionType.ParentRows) this.CollapseAtRowIndex(bookmarks[i]); cm = rs.ListManager as CurrencyManager; cm.List.RemoveAt(rs.Position); } this.Selections.Clear(); this.CurrentCell.MoveTo(this.FirstDataRow, this.Model.Cols.HeaderCount+1); if (rsType == RowSelectionType.ChildRows) { int row = this.Model.RowCount-1; while (row >= this.FirstDataRow) { rs = this.Binder.GetRecordStateAtRowIndex(row); if (rs.LevelIndex == 0 && this.IsExpandedAtRowIndex(row)) { this.CollapseAtRowIndex(row); this.ExpandAtRowIndex(row); } row--; } } this.EndUpdate(); If I delete the only child record, the + sign disappears. What needs to be done to make it visible again? I add child records via a context menu and even if I add a child record to this parent (confirmed that I had a matching foreign key) and do a CollapseAll & ExpandAll, the record doesn''t show up in the grid (and neither does the +).

Lori S. Pearsall
Replied On June 17, 2004 01:52 AM UTC

To add to the previous post, the add logic works fine if there''s already a "+" present.

Administrator [Syncfusion]
Replied On June 17, 2004 05:26 AM UTC

Here is a forum thread that discusses this problem. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=13894

Lori S. Pearsall
Replied On June 17, 2004 12:21 PM UTC

I''m a bit concerned about this approach. My Parent is a DataTable and so is the Child and their relation is a DataRelation. What is the implication of adding a "blank" record under the covers? When I ultimately do a DataAdapter.Update are these blank records going to be pushed to the database?

Administrator [Syncfusion]
Replied On June 17, 2004 12:30 PM UTC

I thought you were trying to add a child record to a parent that currently had no children. (The referenced thread did this, adding the appropriate values so the child record so it was not blank, but was populated with the key values so it satisfied the relation so it was put under the proper parent.) Are you trying to do something else?

Lori S. Pearsall
Replied On June 17, 2004 03:59 PM UTC

No - my mistake. I''ve started doing a ExpandAll/CollapseAll in the Form_Load so that the extraneous "+"''s don''t show up. Now I have a consistent appearance on start-up and when I start deleting child records. Your code did the trick - thanks once again!


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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