DataGridView的只读细胞 [英] DataGridView read only cells

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

问题描述

我有个绑定的DataGridView包含大量数据。的问题是,某些细胞具有当用户使用TAB导航或细胞之间的ENTER为只读并且也将ReadOnly细胞应绕过。什么使某些特定的细胞loadging后只读imediatly的最佳方式?

I have a binded DataGridView that contains a large amount of data. The problem is that some cells has to be ReadOnly and also when the user navigates with TAB or ENTER between cells, the ReadOnly cells should be bypassed. What's the best way of making some specific cells ReadOnly imediatly after loadging?

通过细胞循环后,我设置数据源是不是一个好主意也要考虑到电网有大量的数据。此外,使细胞只读的CellEnter不起作用,因为用TAB键导航时我已经知道,如果下一个单元格是只读或没有。

Looping through cells after I set DataSource is not a good idea taking in consideration that the grid has a large amount of data. Also, making the cell ReadOnly on CellEnter does not work because when navigating with TAB key I have to already know if the next cell is ReadOnly or not.

推荐答案

尽量让列,而不是单个细胞只读之前绑定的数据:

Try to make the column rather than individual cells readonly before binding the data:

this.dgrid.Columns["colName"].ReadOnly = true;

如果您需要为列中的单个细胞做,那么你将不得不环路并将它们是这样的:

If you need to do for individual cells within the column, then you will have to loop and set them like this:

this.dgridvwMain.Rows[index].Cells["colName"].ReadOnly = true;

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

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