如何让 DataGridView 显示选定的行? [英] How do I make the DataGridView show the selected row?

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

问题描述

我需要强制 DataGridView 显示选定的 row.

I need to force the DataGridView to show the selected row.

简而言之,我有一个 textbox,它根据输入到 textbox 中的内容更改 DGV 选择.发生这种情况时,选择会更改为匹配的 row.

In short, I have a textbox that changes the DGV selection based on what is typed into the textbox. When this happens, the selection changes to the matching row.

不幸的是,如果选定的 row 不在视图中,我必须手动向下滚动才能找到选择.有谁知道如何强制 DGV 显示选定的 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 文档 在这个属性上.

Here is the MSDN documentation on this property.

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

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