如何使DataGridView显示所选行? [英] How do I make the DataGridView show the selected row?

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

问题描述

我需要强制DataGridView显示所选行。简而言之,我有一个文本框,根据框中输入的内容更改DGV选择。发生这种情况时,选择将更改为匹配行。不幸的是,如果所选行不在视图中,我必须手动向下滚动以找到选择。有没有人知道如何强制DGV显示选定的行?

I need to force the DataGridView to show the selected row. In short, I have a text box that changes the DGV selection based on what is typed into the box. When this happens, the selection changes to the matching row. Unfortunately if the selected row is out of the view, I have to manually scroll down to find the selection. Does anyone know how to force the DGV to show the selected row?

谢谢!

推荐答案

您可以设置:

dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.SelectedRows[0].Index;

这是 MSDN文档关于此属性。

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

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