利用DataGrid的MouseDown和MouseMove事件,模拟滑动浏览的效果 

int x = 0, y = 0;
private void dataGrid_MouseDown(object sender, MouseEventArgs e)
{
    x = e.X;
    y = e.Y;
}
private void dataGrid_MouseMove(object sender, MouseEventArgs e)
{
    try
    {
        int yy = 0;
        //当前鼠标y坐标值与滑动开始y值的差 给予datagrid 上下滑动距离值
        yy = e.Y - y;
        //25值是datagrid行高值,根据距离给定滑动行数
        yy = yy / 25;
        this.CurrentRowIndex = this.CurrentRowIndex + yy;
    }
    catch
    { }
}

相关文章:

  • 2021-07-28
  • 2021-08-19
  • 2021-11-20
  • 2022-01-21
  • 2021-08-10
  • 2021-10-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-07-31
  • 2022-12-23
  • 2021-09-01
  • 2021-08-14
相关资源
相似解决方案