Example #1
0
        public void update(List <ApplicationRecord> pRecordList)
        {
            bool lIsLastLine    = false;
            int  lLastPosition  = -1;
            int  lLastRowIndex  = -1;
            int  lSelectedIndex = -1;


            lock (this)
            {
                /*
                 * Remember DGV positions
                 */
                if (DGV_Applications.CurrentRow != null && DGV_Applications.CurrentRow == DGV_Applications.Rows[DGV_Applications.Rows.Count - 1])
                {
                    lIsLastLine = true;
                }

                lLastPosition = DGV_Applications.FirstDisplayedScrollingRowIndex;
                lLastRowIndex = DGV_Applications.Rows.Count - 1;

                if (DGV_Applications.CurrentCell != null)
                {
                    lSelectedIndex = DGV_Applications.CurrentCell.RowIndex;
                }

                cApplications.Clear();
                foreach (ApplicationRecord lTmp in pRecordList)
                {
                    cApplications.Add(lTmp);
                }

                // Selected cell/row
                try
                {
                    if (lSelectedIndex >= 0)
                    {
                        DGV_Applications.CurrentCell = DGV_Applications.Rows[lSelectedIndex].Cells[0];
                    }
                }
                catch (Exception) { }


                // Reset position
                try
                {
                    if (lLastPosition >= 0)
                    {
                        DGV_Applications.FirstDisplayedScrollingRowIndex = lLastPosition;
                    }
                }
                catch (Exception) { }

                DGV_Applications.Refresh();
            } // lock (thi...
        }