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. Image for the cookie policy date

How to configure GridTreeStyleManager.RowAppearance from code behind

Is it possible to change the GridTreeControl row appearance during runtime?

Thanks
Ariel

1 Reply

SR Sivakumar R Syncfusion Team May 25, 2012 10:23 AM UTC

Hi Ariel,

You can make use of QueryCellInfo event if you want to style the rows based on some conditions. Please find the code snippet and sample from the below location,

this.AssociatedObject.InternalGrid.QueryCellInfo += InternalGrid_QueryCellInfo;

void InternalGrid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

{

GridTreeNode node = this.AssociatedObject.InternalGrid.GetNodeAtRowIndex(e.Style.RowIndex);

if (node != null)

{

PersonInfo person = node.Item as PersonInfo;

if (person.MyEyeColor.Equals("Red"))

{

e.Style.Foreground = Brushes.White;

e.Style.Background = Brushes.Red;

e.Style.Font.FontWeight = FontWeights.Bold;

}

else if (person.MyEyeColor.Equals("Blue"))

{

e.Style.Foreground = Brushes.White;

e.Style.Background = Brushes.Blue;

e.Style.Font.FontWeight = FontWeights.Bold;

}

else if (person.MyEyeColor.Equals("Brown"))

{

e.Style.Foreground = Brushes.White;

e.Style.Background = Brushes.Brown;

e.Style.Font.FontWeight = FontWeights.Bold;

}

}

}

Screen shot:

Sample:

You can style the Row using GridTreeStyleManager. Please find the same to change the RowStyle using GridTreeStyleManager.

Sample:

Please let me know if you need more details.

Thanks,

Sivakumar

Loader.
Live Chat Icon For mobile
Up arrow icon