Hello,When I fill my TreeView with nodes I always have the first node activatedtreImport.ActiveNode = null has no effectHow can I have no highlighted node ?Thank you
Romain
Hi romain06,
If you are implementing the UltraTree_DropHightLight_DrawFilter_Class, then it is likely that you may be also using a large portion of the Drag and Drop sample where this class is demonstrated.
I took a look at this sample and indeed you were correct, the approach that I suggested is being overridden by the effects of the AppStylist implementation.
The original approach used in that sample does not impede removal of the DrawFocusRect, but it does override the selected appearance.
You can circumvent the undesired selection appearance by not loading the associated isl file, where the selection appearance is being set. As even if the isl file was modified directly, it would still override the effects that we intend to achieve thru code.
//You may comment out this call to the Load() method without impacting the //appearance of the DropHighLight //Infragistics.Win.AppStyling.StyleManager.Load(islFile);
Next, you will need to provide a new selected node appearance, which I will demonstrate in the following code:
//After the node is selected by the user, resume normal selected appearance //including display of the DrawFocusRect void UltraTree1_AfterSelect(object sender, SelectEventArgs e) { UltraTree1.ActiveNode.Override.SelectedNodeAppearance. ResetBackColor(); UltraTree1.ActiveNode.Override.SelectedNodeAppearance. ResetForeColor(); UltraTree1.DrawsFocusRect = DefaultableBoolean.True; }
//When the Tree initially gains focus, remove both selected appearance //as well as the DrawFocusRect void UltraTree1_GotFocus(object sender, EventArgs e) { UltraTree1.DrawsFocusRect = DefaultableBoolean.False; UltraTree1.ActiveNode.Override.SelectedNodeAppearance.BackColor = Color.White; UltraTree1.ActiveNode.Override.SelectedNodeAppearance.ForeColor = Color.Black; }
If you have any further questions regarding this implentation, please let me know.
Sincerely,Chris KDeveloper Support EngineerInfragistics, Inc.www.infragistics.com/support
Hello,Thank you for your answer
I tried your code but it doesn't work in my applicationI always have the focus rectI must have a specific code that take the focus on the treeview but I don't know whatI also use the UltraTree_DropHightLight_DrawFilter_Class class
Is there a way to remove it after it appeared ?
The UltraTree will draw a focus rectangle around the first root node of the tree when the control is brought into focus, (even when ActiveNode is set to null); however, it is certainly possible to give that node an inactive appearance.
Probably the most direct approach would involve modifying the DrawsFocusRect property, extended from the UltraTree.
ultraTree1.DrawsFocusRect = DefaultableBoolean.False;
To maintain otherwise normal appearance for the UltraTree, the DrawsFocusRect property may be set to false during the ultraTree1_GotFocus event and then set back to true, after a node is actively selected in the tree via the ultraTree1_AfterActivate event.
Note that if you intend to produce this behavior each time focus is lost and regained by the UltraTree control, I would also recommend resetting the current selected node.
This can be achieved by selecting an arbitrary node as the selected node during the ultraTree1_GotFocus event and then immediately removing the selection for that node.
Example of implementation:
void ultraTree1_AfterActivate(object sender, NodeEventArgs e) { ultraTree1.DrawsFocusRect = DefaultableBoolean.True; }
void ultraTree1_GotFocus(object sender, EventArgs e) { ultraTree1.Nodes[0].Selected = true; ultraTree1.Nodes[0].Selected = false; ultraTree1.DrawsFocusRect = DefaultableBoolean.False; } If you have any further questions or if I may be of any further assistance regarding this inquiry, please let me know.