难以在DataGridView中设置只读单元格 [英] Difficulty setting readonly cells in DataGridView

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

问题描述

大家好,

这是一个棘手的问题,但是我将尝试在不使用代码的情况下对其进行概述-太多了.

在我的票务系统中,我做出了一个设计决策,即所有静态定义在参与创收交易后都无法修改.从那时起,唯一允许的更改是对行的结束日期.

在舞台定义表单上,我有两个数据网格,StageMaster和StagePrice
StageMaster具有所有阶段定义,并重新填充StagePrice以显示当前所选StageMaster行的所有定价数据.

对于这两个网格,我都会在相关RowEnter事件的一部分上选中"Stage_In_Use"标志,该标志会将我选择的字段设置为只读.

这对于StagePrice效果很好,但对于StageMaster则效果不佳.它失败,因为它导致对SetCurrentAddressCoreFunction的可重入调用.

我认为这是因为StageMaster具有焦点",并且我必须违反模块尝试输入的单元格不可编辑的条件之一.

在显示from之前,将调用RowEnter三次(全部用于第一行).

我的目的是仅在屏幕上显示表单后才激活检查,我该怎么做,或者我应该查看另一种方法?

Good day all,

This is a thorny one but I will try to outline it without code - there is too much of it.

In my ticketing system I made a design decision that all static definitons cannot be amended after they participate in a revenue earning transaction. From that point on the only allowed change is to the row''s end date.

On my stage definition form, I have two data grids, the StageMaster and StagePrice
StageMaster has all the stage definitions and for StagePrice is repopulated to show all the pricing data for the currently selected StageMaster row.

For both grids, I check a ''Stage_In_Use'' flag on as part of the relevant RowEnter event which sets my chosen fields to readonly.

This works very well for StagePrice, but not StageMaster. It fails because it results in a reentrant call to the SetCurrentAddressCoreFunction.

I think this is because StageMaster has ''focus'' and I must be violating one of the conditions where the cell the module tries to enter is not editable.

RowEnter is called three times (all for the first row) before the from is displayed.

My aim is to only activate the check after the form is on screen, how do I do this or is there another approach I should be looking at?

推荐答案

http://www. dotnetmonster.com/Uwe/Forum.aspx/winform-controls/4469/Set-readonly-property-on-cell-level-in-a-datagridview [

这篇关于难以在DataGridView中设置只读单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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