以编程方式在 DataGridView 中选择一行 [英] Selecting a row in DataGridView programmatically

查看:24
本文介绍了以编程方式在 DataGridView 中选择一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时以编程方式在 DataGridView 中选择特定范围的行?

How can I select a particular range of rows in a DataGridView programmatically at runtime?

推荐答案

未测试,但我认为您可以执行以下操作:

Not tested, but I think you can do the following:

dataGrid.Rows[index].Selected = true;

或者您可以执行以下操作(但同样:未测试):

or you could do the following (but again: not tested):

dataGrid.SelectedRows.Clear();
foreach(DataGridViewRow row in dataGrid.Rows)
{
    if(YOUR CONDITION)
       row.Selected = true;
}

这篇关于以编程方式在 DataGridView 中选择一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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