I am using a ultraTree with Outlook ViewStyle and want to display columns having different back colors.
I have tried to apply header apperance back color in ColumnSetGenerated event but it didn't work.
newColumn.HeaderAppearance.BackColor = Color.Red;
Please, can you tell me, whats going wrong?
Thanks
--Sami.
Hi Sami,
HeaderAppearance only affects the column header. Are you saying that the HeaderAppearance is not changing the color of the column header? Or that you are trying to change the appearance of the cells and not the header?
Thanks Mike for your quick reply.
Yes.. HeaderAppearance is not changing the color of the column header.
Sami.
The most common reason for that is that the headers are using operating system themes.There's a KB article about this here:
HOWTO:Change the Color of Column Headers in the WinGrid
The article is talking about the grid, but it's the same issue in the tree. Try setting ThemedElementAlpha to Transparent on the same appearance on which you are setting the BackColor. Or turn off themes for the whole try by setting UseOsThemes to false.
I tried setting ThemedElementAlpha to Transparent , but no luck still HeaderAppearance is not changing the color of the column header.
This is what i am trying to do.
ultraTree.UseOsThemes = DefaultableBoolean.False;
foreach (var column in ultraTree.ColumnSettings.ColumnSets[0].Columns) {
{
column.HeaderAppearance.ThemedElementAlpha =
Alpha.Transparent;
column.HeaderAppearance.BackColor = Color.Red;
}
--SAMI
Are you loading a Style Library (.isl file) into your application?
If the isl file applies a background image to the column headers, then that image would cover the background and you would not be able to see the color.
Its the .isl file that is overriding the column header styles, thanks Mike.
Thanks for support,
Hi Mike,
Yes we are loading Style libraray. Is there any way to override and apply backcolor to the column. or What is the best way to apply backcolor without changing any thing in .isl file.
As a general rule, the appearance settings on an individual object (such as the header of a column) override the appearance on the application level provided by an isl.
But my guess is that in this case the isl file is applying an ImageBackground to the column headers and therefore the image covers up the BackColor. There's nothing you can do about that without either:
1) Remove the image from the isl.
2) Use a DrawFilter to stop the UIElement from drawing the image on this particular element.