PatriceG
PatriceG

Reputation: 4063

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

In a Data Grid table, I would like to change the backgroud color of a "selected" cell.

In the table, the user can select a cell in each row (I used a custom property that I increment each time the user click on the same row). I would like to highlight the selected cell, for instance by changing the bg color of it.

How can I do that ? Thanks a lot.

Upvotes: 0

Views: 547

Answers (4)

PatriceG
PatriceG

Reputation: 4063

I found a way, thanks to the answer of dunbarx, and with adding the use of "the target".

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

Upvotes: 0

dunbarx
dunbarx

Reputation: 756

Do you have data in the "cell" you are interested in? This method will not work if it is empty. "No such object"? It may be that you need this as well:

 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

Upvotes: 0

dunbarx
dunbarx

Reputation: 756

If I make a new DG and fill it with some tab and return delimited text, my handler turns the designated "cell" red.

I do notice that there was a spurious character after "end mouseUp" in my earlier post. I edited it out, but might this have caused your problem?

Upvotes: 0

dunbarx
dunbarx

Reputation: 756

I am fond of saying that I use data grids, but do not understand them.

A dataGrid is just a complex LC object, comprised of other LC objects, groups and behaviors. Each field is designated as, say: fld "Col 1 0002" (first column, second line)

So you could:

  on mouseUp
    set the opaque of fld "col 1 0002" to "true"
    set the backColor of fld "col 1 0002" to "red"
  end mouseUp

Now there may well be a "native" way of doing this, But I do not know it.

Upvotes: 1

Related Questions