在DataGridView中仅使一行只读 [英] Making Just One Row Read-Only in a DataGridView

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

问题描述

我在C#Windows Forms应用程序中有一个DataGridView,它显示来自查询的记录.

如何使某些行(即状态字段设置为已关闭"的行)是只读的?

Brian

I have a DataGridView in a C# Windows Forms app displaying records from a query.

How do I make it so that certain rows (i.e., that have the status field set to ''closed'') are read-only?

Brian

推荐答案

据我所知,您可以通过以下方式将行设置为只读:

Well as far as I know you can make a row readonly by:

dataGridView1.Rows[1].ReadOnly = true;



使用for循环读取gridview中的所有行,如果特定行的状态字段已关闭,则获取其行索引并将其readonly属性设置为"true".

有关更多信息,请参见:

MSDN Datagridview.Readonly属性 [ C#datagridview只读行,列... [



With a for-loop read all the rows in your gridview, if the status field of the specific row is closed, get its row index and set its readonly property to "true".

For further information see:

MSDN Datagridview.Readonly property[^]

C# datagridview readonly row,column...[^]


这篇关于在DataGridView中仅使一行只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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