【发布时间】:2016-12-14 13:22:13
【问题描述】:
在数据网格表中,我想更改“选定”单元格的背景颜色。
在表格中,用户可以在每一行中选择一个单元格(我使用了一个自定义属性,每次用户单击同一行时我都会增加该属性)。我想突出显示选定的单元格,例如通过更改它的背景颜色。
我该怎么做? 非常感谢。
【问题讨论】:
在数据网格表中,我想更改“选定”单元格的背景颜色。
在表格中,用户可以在每一行中选择一个单元格(我使用了一个自定义属性,每次用户单击同一行时我都会增加该属性)。我想突出显示选定的单元格,例如通过更改它的背景颜色。
我该怎么做? 非常感谢。
【问题讨论】:
我喜欢说我使用数据网格,但不了解它们。
dataGrid 只是一个复杂的 LC 对象,由其他 LC 对象、组和行为组成。每个字段都被指定为:fld "Col 1 0002"(第一列,第二行)
所以你可以:
on mouseUp
set the opaque of fld "col 1 0002" to "true"
set the backColor of fld "col 1 0002" to "red"
end mouseUp
现在很可能有一种“本地”的方式来做这件事,但我不知道。
【讨论】:
如果我创建一个新的 DG 并用一些制表符填充它并返回分隔文本,我的处理程序会将指定的“单元格”变为红色。
我确实注意到在我之前的帖子中“end mouseUp”之后有一个虚假字符。我编辑了它,但这可能导致您的问题吗?
【讨论】:
您感兴趣的“单元格”中有数据吗?如果为空,此方法将不起作用。 “没有这样的对象”?可能你也需要这个:
on mouseUp
set the opaque of fld "col 2 0003" of grp "yourDG to "true"
set the backColor of fld "col 2 0003" of grp "yourDG" to "green"
end mouseUp
【讨论】:
我找到了一种方法,感谢 dunbarx 的回答,并添加了“目标”的使用。
on mouseUp
set the opaque of the target to "true"
set the backColor of the target to "green"
end mouseUp
【讨论】: