Hi,
I have a control that is using a custom tree view, the problem that I am having is that when using the 'Windows Classic Theme' in XP (i.e. visual styles are turned off) I get the following error:
Visual Styles-related operation resulted in an error because no visual styles is currently active.
************** Exception Text **************
System.InvalidOperationException: Visual Styles-related operation resulted in an error because no visual style is currently active.
at System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsCombinationDefined(String className, Int32 part)
at System.Windows.Forms.VisualStyles.VisualStyleRenderer..ctor(String className, Int32 part, Int32 state)
at System.Windows.Forms.VisualStyles.VisualStyleRenderer..ctor(VisualStyleElement element)
at AdvancedDataGridView.TreeGridView..ctor()
at ServicesTree.InitializeComponent()
at ServicesTree..ctor(Int32 alertIdIn)
I found a peice of code that may have been using visual styles so I put the following if statement around it:
if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser)
treeGridView1.EnableHeadersVisualStyles = true;
However this did not solve the problem, I have found one more peice of code that uses visual styles:
internal VisualStyleRenderer rOpen = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
...but that's a definition so I can't wrap it in an if statement like above.
Does anybody know how I can get round this? Is it even going to be possible for me to use this treeview with visual styles disabled?
Thanks in advance for any help,
Tom
I have a control that is using a custom tree view, the problem that I am having is that when using the 'Windows Classic Theme' in XP (i.e. visual styles are turned off) I get the following error:
Visual Styles-related operation resulted in an error because no visual styles is currently active.
************** Exception Text **************
System.InvalidOperationException: Visual Styles-related operation resulted in an error because no visual style is currently active.
at System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsCombinationDefined(String className, Int32 part)
at System.Windows.Forms.VisualStyles.VisualStyleRenderer..ctor(String className, Int32 part, Int32 state)
at System.Windows.Forms.VisualStyles.VisualStyleRenderer..ctor(VisualStyleElement element)
at AdvancedDataGridView.TreeGridView..ctor()
at ServicesTree.InitializeComponent()
at ServicesTree..ctor(Int32 alertIdIn)
I found a peice of code that may have been using visual styles so I put the following if statement around it:
if (VisualStyleInformation.IsSupportedByOS && VisualStyleInformation.IsEnabledByUser)
treeGridView1.EnableHeadersVisualStyles = true;
However this did not solve the problem, I have found one more peice of code that uses visual styles:
internal VisualStyleRenderer rOpen = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
...but that's a definition so I can't wrap it in an if statement like above.
Does anybody know how I can get round this? Is it even going to be possible for me to use this treeview with visual styles disabled?
Thanks in advance for any help,
Tom