Hello,
i'm using a UltraWinTree, which has a assigned style set. This style set uses a specific font, which can probably be changed by the user of the application.
Now i'm trying to get the System.Drawing.Font of a UltraTreeNode from this tree at runtime. "Override.NodeAppearance.FontData" always returns me "default" or NULL/"0" values. When i call "ResolveAppearance" on the UltraTreeNode, the resulting Infragistics.Win.AppearanceData.FontData object also contains only default values. Calling CreateFont returns me NULL.
Can you please explain, how i can get the System.Drawing.Font of a UltraTreeNode?
Thank you in advance for your help!
Best regards,
Daniel
UltraTreeNode exposes a ResolveAppearance method, which is designed for exactly this purpose. In your case you would code something like this:
UltraTreeNode node;
AppearancePropFlags flags = AppearancePropFlags.FontData;
AppearanceData data = new AppearanceData();
node.ResolveAppearance(ref data, ref flags);
When execution returns from the ResolveAppearance method, the AppearanceData struct will be initialized with the resolved value(s). You could then use it's CreateFont method to create the same font as the one currently being used by that node.
Thank you for your reply. As i mentioned, i've already tried the "ResolveAppearance"-method, without success.
I've created a simple test application with one form, a button and a UltraWinTree. The button does the following:
/* Code start */
UltraTreeNode unRoot;AppearanceData data = new AppearanceData(); AppearancePropFlags flags = AppearancePropFlags.FontData;
Font foTest;
this.ultraTree1.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.FreeForm;
unRoot = this.ultraTree1.Nodes.Add("Root");
unRoot.Text = "Test";
unRoot.ResolveAppearance(ref data, ref flags);
foTest = data.CreateFont(new Font("Microsoft Sans Serif", 8));
/* Code end */
data.FontData still contains the default values after calling ResolveAppearance. foTest is NULL after the "CreateFont"-call.
What am i doing wrong?
Terribly sorry, I should have read the whole thing. Unfortunately there is no ResolveCellAppearance method, and when ViewStyle is set to anything other than Standard, the control displays cells and most of the node-related appearances are non-applicable.
Technically something like this would be a new feature request, but since we already have a way to do this internally, it would just be a matter of making the method public, so you should probably report this as a bug, and we would "fix" it for the next service release.
If you're really in a rush to get this you could use reflection to get access to the internal method, although we don't recommend doing this since internal members can change unexpectedly across releases, in which case your code could break.