WinCE上下滑动浏览数据
利用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
{ }
}
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
{ }
}
作者:sy
出处:http://www.cnblogs.com/sydeveloper
QQ:522733724
本页版权归作者和博客园所有,欢迎转载,但未经作者同意必须保留此段声明,
且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利