DataGridView中实现上一页,上一行,下一行,下一页的功能
2013-08-22 09:00
405 查看
DataGridView中实现上一页,上一行,下一行,下一页的功能:
属性设置:
SelectionMode——FullRowSelect
MultiSelct——false
AllowUserToResizeRows——false
AllowUserToResizeColumns——false
//以下的DataGridView在窗口中可视的行数为15。
private void btnNextRow_Click(object sender, EventArgs e)
{
if (dgvPlaneInfo.CurrentCell.RowIndex < dgvPlaneInfo.Rows.Count - 1)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.CurrentCell.RowIndex + 1];
}
else
{
MessageBox.Show("当前已是最后一行", "提示");
}
}
private void btnLastRow_Click(object sender, EventArgs e)
{
if (dgvPlaneInfo.CurrentCell.RowIndex != 0)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.CurrentCell.RowIndex - 1];
}
else
{
MessageBox.Show("当前已是第一行", "提示");
}
}
private void btnNextPage_Click(object sender, EventArgs e)
{
if (dgvPlaneInfo.Rows.Count - dgvPlaneInfo.CurrentCell.RowIndex > 15)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.CurrentCell.RowIndex + 15];
}
else if (dgvPlaneInfo.Rows.Count - dgvPlaneInfo.CurrentCell.RowIndex > 1)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.Rows.Count - 1];
}
else
{
MessageBox.Show("当前已是最后一页", "提示");
}
}
private void btnLastPage_Click(object sender, EventArgs e)
{
if (dgvPlaneInfo.CurrentCell.RowIndex > 14)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.CurrentCell.RowIndex - 15];
}
else if (dgvPlaneInfo.CurrentCell.RowIndex <= 14 && dgvPlaneInfo.CurrentCell.RowIndex != 0)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, 0];
}
else
{
MessageBox.Show("当前已是第一页", "提示");
}
}
属性设置:
SelectionMode——FullRowSelect
MultiSelct——false
AllowUserToResizeRows——false
AllowUserToResizeColumns——false
//以下的DataGridView在窗口中可视的行数为15。
private void btnNextRow_Click(object sender, EventArgs e)
{
if (dgvPlaneInfo.CurrentCell.RowIndex < dgvPlaneInfo.Rows.Count - 1)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.CurrentCell.RowIndex + 1];
}
else
{
MessageBox.Show("当前已是最后一行", "提示");
}
}
private void btnLastRow_Click(object sender, EventArgs e)
{
if (dgvPlaneInfo.CurrentCell.RowIndex != 0)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.CurrentCell.RowIndex - 1];
}
else
{
MessageBox.Show("当前已是第一行", "提示");
}
}
private void btnNextPage_Click(object sender, EventArgs e)
{
if (dgvPlaneInfo.Rows.Count - dgvPlaneInfo.CurrentCell.RowIndex > 15)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.CurrentCell.RowIndex + 15];
}
else if (dgvPlaneInfo.Rows.Count - dgvPlaneInfo.CurrentCell.RowIndex > 1)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.Rows.Count - 1];
}
else
{
MessageBox.Show("当前已是最后一页", "提示");
}
}
private void btnLastPage_Click(object sender, EventArgs e)
{
if (dgvPlaneInfo.CurrentCell.RowIndex > 14)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, dgvPlaneInfo.CurrentCell.RowIndex - 15];
}
else if (dgvPlaneInfo.CurrentCell.RowIndex <= 14 && dgvPlaneInfo.CurrentCell.RowIndex != 0)
{
dgvPlaneInfo.CurrentCell = dgvPlaneInfo[0, 0];
}
else
{
MessageBox.Show("当前已是第一页", "提示");
}
}
相关文章推荐
- 从数据库中提出数据,实现图片上一页、下一页的翻页功能?
- 毕业设计(十二)---后台用户管理(2)之- 分页 实现上一页,下一页,跳页功能
- 毕业设计(十二)---后台用户管理(2)之- 分页 实现上一页,下一页,跳页功能
- C# winform datagridview中如何实现鼠标右键点击一行数据出现一个带有删除的菜单,并能执行删除操作?
- 实现datagridview中数据的添加,更改,删除功能
- ASP.NET 分页实现源码(上一页 下一页共页数 第几页)
- [原创]Asp.net2.0 VS 2005下的repeater控件本功能分页实例(共有 条记录 共有几页 当前第 页 首页,上一页,下一页,尾页 DropDownList跳转)
- 在 DataGridView 中实现类似 Ctrl + F 的查找功能
- DataGridView中添加一行时自动生成序列行,未实现
- JavaScript动态实现表格添加、删除、插入、上移、下移一行功能
- PHPCMS点击图片进入下一页功能的实现方法
- java 实现JSP页面上一页及下一页封装
- 一行代码完成 调用系统相册 和 视频,语音库,选择图片,视频,和音频文件。在选择界面实现了录制视频和录制音频功能。 截图
- DataGridView分页功能的实现
- dataGridView绑定泛型的筛选功能实现
- DataGridView分页功能的实现
- PHP简单实现上一页下一页功能示例
- jsp实现上一页下一页翻页功能(示例代码)
- 如何实现返回上一页并刷新页面的功能
- Android开发实现上一页,下一页显示内容