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 

DataRow Binding Style.BackColor

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



Joined: 21 Jun 2005
Posts: 89
Location: Switzerland

PostPosted: Wed Sep 21, 2005 12:14 pm    Post subject: DataRow Binding Style.BackColor Reply with quote

Hello Support

I have set the Style.BackColor on a DataRow Binding. I expected that the entire row will be colored with the BackColor, but in fact only the Region that is not bound will be colored.



Is this a Bug? btw how to set a BackColor for a specific level?

Thanks and Best Regards
Giuseppe
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Sep 21, 2005 10:06 pm    Post subject: Reply with quote

No this isn't a bug. The problem is that you can either view a table as a collection of columns or as a collection of rows. So you can set up the style hierarchy to make it easy to change styles by column or by row - but not both (at least not without becoming very complicated). We made the decision that it was more common to want to change the style by column and set up the style hierarchy accordingly.

You can still change the style for a single row - but you need to change the style for each cell of the row (as well as the row). If you are using Object Bindings this is still easy - simply select all the CellBindings for the row in question and the row binding itself (by using the shift or control keys when selecting). Then change the style for all of them at once.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
flc.net



Joined: 21 Jun 2005
Posts: 89
Location: Switzerland

PostPosted: Thu Sep 22, 2005 7:48 am    Post subject: Reply with quote

Hello Support

I hope you don't get mad about all my posts.

Setting the CellBinding BackColor is ok. But with this implementation is not possible to set the BackColor for a VT.Column that is not Bound to a DataColumn.

The Only way to set the BackColor for the entire Row (based on the Level) is on "GetCellData". This is a little bit inconvenient Wink

Best Regards
Giuseppe
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Sun Sep 25, 2005 9:55 am    Post subject: Reply with quote

You can create a CellBinding for a column even if you are programmatically setting the CellData.Value in the GetCellData. In fact this is a good idea since you can let the CellBinding do most of the work and only do the bits programmatically that really can't be done at design time. The first line of code in your GetCellData event/method should call GetRowBinding to get the rowbinding and the call the RowBinding.GetCellData method.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
NJDRZ
Guest





PostPosted: Wed Nov 09, 2005 9:49 pm    Post subject: determing a row's backcolor based on a cell value Reply with quote

How can I apply a unique backcolor to a row based on the value of a cell? For example if Column 1 has the value of "A" the backcolor is set to blue and for a value of "B" the backcolor is to green.
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Nov 09, 2005 11:27 pm    Post subject: Reply with quote

If there are a fixed number of different styles that you want to apply then the best way to do this is to create a separate RowBinding for each type of row and set up the styles (colors etc) in the RowBindings editor. Then you can handle the GetBinding event (or override the GetRowBinding method) to select the row binding (and hence visual style) based on the item properties.

An alternative is to handle the GetRowData and GetCellData events (or override the corresponding methods) and set the OddStyle and EvenStyle properties of the CellData/RowData programmatically. Note that because rows share references to styles (to conserve resources) you can't just set the BackColor of the existing style - as this will change the colors of all rows using that style. Instead you need to assign a separate style. You can create new styles on the fly in the GetRowData/GetCellData methods eg

Code:
 
private void _virtualTree_GetCellData(object sender, GetCellDataEventArgs e)
{
    // get the default settings using the row binding
    //
    RowBinding binding = _virtualTree.GetRowBinding(e.Row);
    binding.GetCellData(e.Row, e.Column, e.CellData);

    // check if you want to highlight this item
    //
    if (e.Row.Item == "A")
   {
        Style highlightStyle = new Style(_virtualTree.RowStyle);
        highlightStyle.BackColor = Color.Red;
        e.CellData.OddStyle = highlightStyle;
        e.CellData.EvenStyle = highlightStyle;
    }
}


This has the performance disadvantage that you are creating new styles all the time - so it would be better to setup the style at initialization in a member variable if possible and then just assign it in the GetCellData/GetRowData events.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
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