View previous topic :: View next topic |
Author |
Message |
jmaeding
Joined: 11 Apr 2008 Posts: 67
|
Posted: Tue Mar 01, 2011 4:44 pm Post subject: access cellwidget during SetValueForCell |
|
|
sorry to be posting so many basic questions, but here is another.
To accomplish coloring cell text, I am using a custom cell widget for certain cells.
One of them is a status column, where I use a combobox to select "ToDo", "Skip", or "Done".
I want to color the cell based on the value, so was thinking that would happen in the event that changes the value for the data.
My custom cellwidget has a color property, so I wanted to change it.
I have a feeling its the wrong event to do this in though, as SetValueForCell only provides row and column objects, not enough to get to the cellwidget, right?
I guess this question comes down to how to modify the cellwidget when a change happens to the cell value.
thx _________________ James M |
|
Back to top |
|
|
jmaeding
Joined: 11 Apr 2008 Posts: 67
|
Posted: Tue Mar 01, 2011 4:56 pm Post subject: |
|
|
oh, maybe this.GetCellWidget(row, column)?
still, I am wondering if this is the right way to do things - modifying the cell widget.
What if I decide the cell needs a different cell widget altogether due to some change? _________________ James M |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Mar 01, 2011 9:25 pm Post subject: |
|
|
You want to make your CellWidget code data driven - ie it should decide the color to draw the text based on the data. That way when something changes all you have to do is get the CellWidget to update its data and redraw by calling VirtualTree.UpdateRowData(Row row). The same logic is then called whether the CellWidget is drawn normally or after a change. _________________ Infralution Support |
|
Back to top |
|
|
jmaeding
Joined: 11 Apr 2008 Posts: 67
|
Posted: Wed Mar 30, 2011 12:34 am Post subject: |
|
|
thanks for the reply.
I think to teach the cellwidget what color it should be, I can throw in a function to calculate it from the cell's data.
I am not sure what event that would be in though.
I know the initial creation of the cellwidget is in the CreateCellWidget of the virtual tree, but not what the "updated" event is for the widget.
Where would I put that color calculator function? _________________ James M |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Mar 30, 2011 12:44 am Post subject: |
|
|
Unless the calculation of the color is really expensive then the safest and easiest place to call it is when the cell is drawn ie override PaintText or PaintForeground and call it. _________________ Infralution Support |
|
Back to top |
|
|
jmaeding
Joined: 11 Apr 2008 Posts: 67
|
Posted: Thu Mar 31, 2011 3:23 am Post subject: |
|
|
hmm, I figured that would be too slow, but actually its never very complex. I'll try the paint event. _________________ James M |
|
Back to top |
|
|
jmaeding
Joined: 11 Apr 2008 Posts: 67
|
Posted: Thu Mar 31, 2011 3:50 am Post subject: |
|
|
very good guys, that worked great!
I'll see if I can buy the upgrade to latest version, I now have solved the issues needed to use VT in a bunch of tools. thx a bunch. _________________ James M |
|
Back to top |
|
|
|