简体   繁体   English

如何更改DataGridView中所有突出显示的行-VB.NEt

[英]How to change all highlighted rows in DataGridView - VB.NEt

Begginer's question. 贝金纳的问题。 I'm trying to write small piece of code in Visual Studio (VB.net) that will change value of a particular field of the database for all highlightetd rows. 我正在尝试在Visual Studio(VB.net)中编写一小段代码,该代码将更改所有突出显示行的数据库特定字段的值。 So, I'm running my form, which displays some data from the datatabse. 因此,我正在运行我的表单,该表单显示了来自datatabse的一些数据。 I then highlight some rows (holding Ctrl and clicking). 然后,我突出显示一些行(按住Ctrl并单击)。 Next I click a button that will trigger a value change for all the highlighted rows (only). 接下来,我单击一个按钮,该按钮将触发所有突出显示的行的值更改(仅)。 Say, I want to change the "Name" column's value for all of them. 说,我要为所有这些更改“名称”列的值。

Hope this makes sense. 希望这是有道理的。 Thanks! 谢谢! Damo 达摩

The DataGridView.SelectedRows property contains a collection of all of the rows that the user has selected. DataGridView.SelectedRows属性包含用户选择的所有行的集合。 You can spin through this collection and do what you wish with each row. 您可以浏览此集合,然后对每一行进行所需的操作。

See this article for more information and example code. 有关更多信息和示例代码,请参见本文

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM