LiveCode:如何更改数据网格中单元格的背景颜色

LiveCode: How to change the background color of a cell in a Data Grid

在数据网格 table 中,我想更改 "selected" 单元格的背景颜色。

在 table 中,用户可以 select 每行中的一个单元格(我使用了自定义 属性,每次用户单击同一行时我都会递增)。我想突出显示 selected 单元格,例如通过更改它的 bg 颜色。

我该怎么做? 非常感谢。

我喜欢说我用的是数据网格,但是不懂

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

现在可能有 "native" 方法可以做到这一点,但我不知道。

如果我创建一个新的 DG 并用一些制表符和 return 分隔文本填充它,我的处理程序会将指定的 "cell" 变为红色。

我确实注意到在我之前的 post 中 "end mouseUp" 之后有一个虚假字符。我已将其编辑掉,但这是否会导致您的问题?

"cell" 中有您感兴趣的数据吗?如果为空,此方法将不起作用。 "No such object"?可能你也需要这个:

 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 的回答,并添加了 "the target".

on mouseUp 
    set the opaque of the target to "true"
    set the backColor of the target to "green"
end mouseUp