Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

access cellwidget during SetValueForCell

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Tue Mar 01, 2011 4:44 pm    Post subject: access cellwidget during SetValueForCell Reply with quote

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
View user's profile Send private message
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Tue Mar 01, 2011 4:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Mar 01, 2011 9:25 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Wed Mar 30, 2011 12:34 am    Post subject: Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Mar 30, 2011 12:44 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Thu Mar 31, 2011 3:23 am    Post subject: Reply with quote

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
View user's profile Send private message
jmaeding



Joined: 11 Apr 2008
Posts: 67

PostPosted: Thu Mar 31, 2011 3:50 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group