Disable hot-track problem?

Hi,

I am using hot-tracking,

Is there a way to ignore this setting on certain nodes?

I am looking for an e.cancel=true

but they seem didn't work in nodebeforepaint. (e.handled=true overrides everything)

Is there a way to achieve this?


A temporary solution I came up with is to repaint the background but I am not sure what brushinfo settings to repaint exactly like that.

Ex:  n.Background = New BrushInfo(BackwardDiagonal, Color.Red, Color.Yellow) (how to redraw this color in Nodebeforepaint)


Thanks you!

jamin.


5 Replies 1 reply marked as answer

SB Sweatha Bharathi Syncfusion Team January 29, 2025 01:04 PM UTC

Hi jamin ,

We have reviewed your query. To achieve your requirement of ignoring hot tracking for certain nodes, you can accomplish this by using the BeforeNodePaint event. In this event, set e.HotTracked to false and configure the ForeColor . Kindly refer to the code snippet below, and please let us know if you have any further concerns.


Code snippet :

  private void TreeViewAdv1_BeforeNodePaint(object sender, TreeNodeAdvPaintEventArgs e)
  {          
      if(e.Node.Text == "Parent1")
      {
          e.HotTracked = false;
          e.ForeColor = Color.Black;
      }
  }





Regards,
Sweatha.B


JA jamin January 29, 2025 03:05 PM UTC

Hi  Sweatha,


I tried but the node background color is still overwritten by the hot-track color.

Is there a way to handled-background? (currently I see it is ignoring text highlight)


Thank you!

jamin



SB Sweatha Bharathi Syncfusion Team January 30, 2025 02:13 PM UTC

Hi jamin ,

We have reviewed your query and suspect that you are applying a style to the TreeViewAdv. When you enable hot tracking, the background, underline, and forecolor are applied to the node. However, when hot tracking is disabled using our previous provided suggestion, the background color still remains.

Can you confirm if this is the scenario you reported? If so, could you please share details about the style you are using? If not, kindly provide a video demonstration of the issue or a code snippet. This information will help us proceed further and provide a better solution.


Image reference when enable hot tracking :


 when disable hot tracking using our previous provide code snippet:



Regards,
Sweatha.B


JA jamin January 30, 2025 06:47 PM UTC

Hi Sweatha,

I have attached a demo and description file.


Thanks you,

jamin.


Attachment: test_a5c02288.rar


SB Sweatha Bharathi Syncfusion Team January 31, 2025 12:38 PM UTC

Hi jamin ,



We have reviewed the sample you provided. As we suspected, the style you are using for the TreeViewAdv in your sample is causing the background to be applied to the hovered node. To prevent this, you can disable the background on hover by using the NodeBackgroundPaint event. In this event, you can handle the background for specific nodes.

 We have modified the sample you provided accordingly. Please review it and let us know if you have any concerns.



Code snippet : 

 private void TreeViewAdv1_NodeBackgroundPaint(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvPaintBackgroundEventArgs e)
 {
     if(e.Node.Text == "Node3")
     {
         e.Handled = true;
     }
 }





Regards,
Sweatha.B

Attachment: WindowsFormsApp1_4e89d970.zip

Marked as answer
Loader.
Up arrow icon