如何在datagridview中显示最后一行 [英] how to show last row in datagridview

查看:932
本文介绍了如何在datagridview中显示最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想显示最后添加到数据库中的第i行gridview。

解决方案

如果它是Winform,滚动到的DataGridView的底部,

<预郎= C#> dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount-1;


在sql中尝试此查询...



 选择 * 来自 TableName 其中 id  in 选择 max(id)来自 TableName)


如果你想从你的数据库中获取最后一条记录并在你的网格中显示,你可以使用Top 1

从日期字段desc中选择tb_man命令的顶部1 *


hi
I want to display row i gridview which is last added in database.

解决方案

If it is a Winform, to scroll to bottom of DataGridView,

dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount-1;


try this query in sql...

select * from TableName where id in (select max(id) from TableName) 


If you want to get last one record from your db and show in your grid, you can use the Top 1
"select top 1 * from tb_man order by datefield desc"


这篇关于如何在datagridview中显示最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆