We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Setting BackColor for each level

Thread ID:

Created:

Updated:

Platform:

Replies:

29951 Jun 8,2005 03:10 AM UTC Jun 8,2005 06:14 PM UTC WinForms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On June 8, 2005 03:10 AM UTC

Hi, How can I set the different ‘BackColor’ for each level when using GDBG in a hierarchical view? Based on the user action and data each ‘level’ will dynamically change the ‘BackColor’. I can’t do that at design time or at the time of form load. I have to do this runtime in response to a user action. I understand that I need to do something like level.RowStyle.BackColor = Color.Red; But I don’t know how to get all the ‘levels’. Starting from ‘root’ to the last level. Thanks, Philip

Administrator [Syncfusion]
Replied On June 8, 2005 09:15 AM UTC

Given a grid row index, you can get the level index for the row using: GridBoundRecordState state = this.grid.Binder.GetRecordStateAtRowIndex(rowIndex); int levelIndex = state.LevelIndex; Then you can use GridHierarchyLevel level = this.grid.Binder.GetHierarchyLevel(levelIndex) to get the GridHierarchyLevel if you know the level index you want.

Administrator [Syncfusion]
Replied On June 8, 2005 02:02 PM UTC

If I know that I have 3 levels in my grid then can I use GridHierarchyLevel level = this.grid.Binder.GetHierarchyLevel(0) GridHierarchyLevel level = this.grid.Binder.GetHierarchyLevel(1) GridHierarchyLevel level = this.grid.Binder.GetHierarchyLevel(2) Or I have to go thru the ‘GetRecordStateAtRowIndex’, my problem is that this way I have to loop thru each row of the grid and then get the levelindex and then actual level. Please advise. thanks, Philip

Administrator [Syncfusion]
Replied On June 8, 2005 02:28 PM UTC

Can i use your suggestion/code in prepareviewstyle event or its too late? Philip

Administrator [Syncfusion]
Replied On June 8, 2005 06:14 PM UTC

In PrepareViewStyleInfo, I think you can use code like this:
if(e.RowIndex > grid.Model.Rows.HeaderCount)
{
     GridBoundRecordState state = this.grid.Binder.GetRecordStateAtRowIndex(rowIndex);
     int levelIndex = state.LevelIndex;
     if(levelIndex == 0)
         e.Style.BackColor = Color.Red;
     else if(levelIndex == 1)
         e.Style.BackColor = Color.Blue;
     else
         e.Style.BackColor = Color.Green;
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;