当搜索时,使DataGridView中的当前行处于画面中段

高手写的:

IDC_DGV_HOSTONLINETRACER.FirstDisplayedScrollingRowIndex =Math.Max(0, row.Index -      this.IDC_PNL_GDV_HOSTONLINE_TRACE_INORMATION.VScrollBar.BMLargeChange / 2);

  this.IDC_DGV_HOSTONLINETRACER.CurrentCell = (ite as OnlineTracerIterator).ElemCurr;

我写的:

int FirstDisplayRowIndex = this.IDC_DGV_HOSTONLINETRACER.FirstDisplayedScrollingRowIndex;

            int CurrentRowIndex = this.IDC_DGV_HOSTONLINETRACER.CurrentRow.Index;

                       if ((CurrentRowIndex - FirstDisplayRowIndex) > MAX_ROW_COUNT_IN_ONE_PAGE / 2)

     {  

 this.IDC_DGV_HOSTONLINETRACER.FirstDisplayedScrollingRowIndex = CurrentRowIndex - MAX_ROW_COUNT_IN_ONE_PAGE / 2;

  }

你可能感兴趣的:(当搜索时,使DataGridView中的当前行处于画面中段)