开发者

using vscrollbar to scroll a xtragrid

开发者 https://www.devze.com 2023-03-08 17:09 出处:网络
Is it possible to handle xtragrid\'s scrollbar via DevExpress.XtraEditors.VScrollBar? something like this:

Is it possible to handle xtragrid's scrollbar via DevExpress.XtraEditors.VScrollBar?

something like this:

private void vScrollBar1_ValueChanged(object开发者_开发问答 sender, EventArgs e)
{
     gridView1.vScrollValue=VScrollBar1.Value;
}

Thanks in advance.


There is no way to do a smooth vertical scrolling with the xtragrid. The scrolling is performed by rows.

To do that, use the Scroll event of the VScrollBar:

   private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
   {     
        GridViewInfo viewInfo = gridView1.GetViewInfo() as GridViewInfo;
        if (viewInfo != null)
        {
            gridView1.TopRowIndex = (int)(
                      (gridView1.RowCount - viewInfo.RowsInfo.Count)
                      *
                      (1 + (1.0 * vScrollBar1.LargeChange / vScrollBar1.Maximum))
                      *
                      vScrollBar1.Value / vScrollBar1.Maximum
                     );
        }
    }

Where:

  • viewInfo.RowsInfo.Count = visible rows count
    • gridView1.RowCount - viewInfo.RowsInfo.Count = maximum index that can be set to be the top.
  • vScrollBar1.Value / vScrollBar1.Maximum = percentage scrolled of the scrollbar.


  vScrollBar1.Maximum = gridView1.RowCount - gridView1.RowCount / 17;

    private void vScrollBar1_ValueChanged(object sender, EventArgs e) 
    { 
        gridView1.TopRowIndex = vScrollBar1.Value; 
    } 

    private void gridView1_TopRowChanged(object sender, EventArgs e) 
    { 
       vScrollBar1.Value = gridView1.TopRowIndex;
    } 

    gridView.MouseWheel += new MouseEventHandler(gridView1_TopRowChanged);
0

精彩评论

暂无评论...
验证码 换一张
取 消