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
110
ultraGrid selected Rows change efficiency
posted

Hi


I set contextmenuStrip for the ultraGrid.Click the button of the contextmenuStrip to
select the ultraGrid all rows.The currnet UltraGrid has the least 5000 data.
Then change the selected row in a column of data.
Such as:
   this.UltraGrid.ActiveRow = null;
            this.UltraGridSelected.Rows.Clear();
            for (int i = 0; i < this.UltraGrid.Rows.Count; i++)
            {
                this.UltraGrid.Rows[i].Selected = true;
            }
(Or use the foreach,Bind)

   if (this.UltraGrid.Selected.Rows.Count > 1)
                {
                   for (int i = 0; i < this.UltraGridSelected.Rows.Count; i++)
                   {
                     this.UltraGrid.Selected.Rows[i].Cells["Cloumn6"].Value = strProType;
                   }
                }


But this efficiency is very low,resulting in slow page.
There is better way to solve this problem?

  • 69832
    Offline posted

    Note that this only works in a single band grid, but this code uses the ISelectionManager interface to range select rows, which applies the selection in one atomic operation rather than one for each row:

    private void SelectAllRows( UltraGrid grid )
    {
        UltraGridRow first = grid.Rows.Count > 0 ? grid.Rows[0] : null;
        UltraGridRow last = grid.Rows.Count > 0 ? grid.Rows[grid.Rows.Count - 1] : null;

        if ( first != null && last != null )
        {
            ISelectionManager selectionManager = grid as ISelectionManager;
            selectionManager.SetPivotItem( first, false );
            selectionManager.SelectItem( first, false );
            selectionManager.SelectRange( last, false );
        }
    }