Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
No ActiveRow after delete
posted
Hi, i have a simple problem, but i'm not able to solve it (in a simple way, without BeforeRowsDeleted, AfterRowsDeleted etc...) Is there a possibility to have always an active row? After deletion of the active row, the user is not able to press delete again, because ActiveRow == null. First he has to click into the grid, then he can delete the next row. The System.Windows.Forms.TreeView control selects the next node after deletion. How can i change this behavior? thanks,
Parents
  • 1467
    posted

    The code below is what I did to partially solve this problem. DataAccess.DeleteRow is a method that deletes the row from the database and the dataset that is bound to the grid. 

    I thinki that if Inragistics spent more time making their existing code do what it should do, instead of adding features, we wouldn't need hacks like this. 

                void M3EditableGrid_BeforeRowsDeleted(object sender, BeforeRowsDeletedEventArgs e)

                {

                      UltraGridRow[ rows = e.Rows;

                      if (rows.Length > 0 && RemoveButton != null)

                      {

                            foreach (UltraGridRow row in rows)

                            {

                                  if (row.HasPrevSibling())

                                        _previousRow = row.GetSibling(SiblingRow.Previous);

                                  else

                                        _previousRow = row.ParentRow;

                                  DataAccess.DeleteRow(row, (DataSet)this.DataSource);

                            }

                      }

                      else

                            e.Cancel = true;

                }

     

                void M3EditableGrid_AfterRowsDeleted(object sender, EventArgs e)

                {

                      if (_previousRow != null)

                      {

                            _previousRow.Activate();

                      }

                      UpdateButtons(); ;

                      this.Focus();

                }

     

Reply Children