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 

Different style for each cell

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



Joined: 04 May 2006
Posts: 7

PostPosted: Thu May 04, 2006 10:55 am    Post subject: Different style for each cell Reply with quote

Hello,

I use programmatic data binding and I need different appearances of rows that are bound to the same item type. I intuitively tried to set e.CellData.Style by there is not property like this. However there are properties e.CellData.EvenStyle/OddStyle, but these properties modify cell style of all rows instead of to modify only style of the processing cell. How should I solve this problem, could you help me please?

Code:
private void tree_GetCellData(object sender, GetCellDataEventArgs e)
{
   if (e.Row.Item is MyItem)
   {
      MyItem item = (e.Row.Item as MyItem);

      e.CellData.Value = item.Value;
      if (item.Active) e.CellData.Style.ForeColor = Color.Red;  // I expected Style property
   }
}
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu May 04, 2006 10:42 pm    Post subject: Reply with quote

You can't just set the color property of the style - this will set the color of all cells that use this style (which by default is every cell in the tree). If you want a cell to have a different color then you need to assign it a new (or different) Style. For example in GetCellData you could do:

Code:

Style highlightStyle = new Style(cellData.OddStyle);
highlightStyle.Color = Color.Red;
cellData.EvenStyle = highlightStyle;
cellData.OddStyle = highlightStyle;


If you know upfront what colors/styles you need it would be better for performance to create the highlight style in your constructor and just do the assignments in GetCellData.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Mrdec



Joined: 04 May 2006
Posts: 7

PostPosted: Thu May 04, 2006 11:02 pm    Post subject: Reply with quote

Thanks, it works fine Smile
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