We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

treeViewAdv node enable/disable

Hello,

I have a problem with Syncfusion TreeViewAdv control (version: 4.302.0.30). When I disable the node on the control using Enabled property = false, it displays the node in the disable state (grey out), but still I am able to select that node with mouse click. I want the node to be not selected in disable mode. How can I do that ?

thanks

Rasesh

6 Replies

AD Administrator Syncfusion Team November 16, 2006 02:28 AM UTC

Additionally, I am using the .net Framework 2.0 for my development. thanks.

>Hello,

I have a problem with Syncfusion TreeViewAdv control (version: 4.302.0.30). When I disable the node on the control using Enabled property = false, it displays the node in the disable state (grey out), but still I am able to select that node with mouse click. I want the node to be not selected in disable mode. How can I do that ?

thanks

Rasesh


MA Malarvizhi Syncfusion Team November 16, 2006 07:34 AM UTC

Hi Rasesh,

To Prevent the node being selected, you could handle the TreeViewAdv.BeforeSelect Event. This event occurs before a node is selected.The event handler receives an argument of type TreeViewAdvCancelableSelectionEventArgs containing data related to this event. The TreeViewAdvCancelableSelectionEventArgs cancel property is set to true, prevents the current node being selected.


private void treeViewAdv1_BeforeSelect(object sender, Syncfusion.Windows.Forms.Tools.TreeViewAdvCancelableSelectionEventArgs args)
{

if (!(args.SelectedNodes[0].Enabled))
{
args.Cancel = true;

}
}


I have attached a sample,please go through that and let me know if you need further assistance.

TreeViewAdvSelect.zip


Regards,
Malarvizhi.


RC Rasesh Chauhan November 16, 2006 09:06 PM UTC

Hi Malarvizhi,

Thanks for your reply. It does help. But still user can click on the node and it draws the rectangle around the node. I do not want the node to be focused at all. How do I that ?

In your given example you are also using NodeBackgroundPaint event. When does it fire ? because it is not firing, in my program.

thanks

Rasesh

>Hi Rasesh,

To Prevent the node being selected, you could handle the TreeViewAdv.BeforeSelect Event. This event occurs before a node is selected.The event handler receives an argument of type TreeViewAdvCancelableSelectionEventArgs containing data related to this event. The TreeViewAdvCancelableSelectionEventArgs cancel property is set to true, prevents the current node being selected.


private void treeViewAdv1_BeforeSelect(object sender, Syncfusion.Windows.Forms.Tools.TreeViewAdvCancelableSelectionEventArgs args)
{

if (!(args.SelectedNodes[0].Enabled))
{
args.Cancel = true;

}
}


I have attached a sample,please go through that and let me know if you need further assistance.

TreeViewAdvSelect.zip


Regards,
Malarvizhi.


MA Malarvizhi Syncfusion Team November 17, 2006 05:59 AM UTC

Hi Rasesh,

We regret for the inconvenience caused.

The TreeviewAdv.OwnerDrawNodesBackground property value indicates,if the NodeBackgroundPaint event will be fired before drawing a node's background. To hide the rectangle drawn around the disabled node,you could handle this event.

I have attached a modified sample,please go through that and let me know if you need further assistance.

TreeViewAdvSelect.zip


Regards,
Malarvizhi.


RC Rasesh Chauhan November 20, 2006 04:49 PM UTC



Hi Malarvizhi,

Thanks for your reply. I still need to implement with the disable nodes:
1) When we click on disable node, the enabled presently selected node should not loose the focus (it should have the rectangle around the node stable, should not flick).
2) when we double click on the disabled node, it should not collapse or expand the children nodes underneath it, if it is a parent node.

thanks

Rasesh


MU Murugan Syncfusion Team November 20, 2006 09:05 PM UTC

Hi Rasesh,

1.This can be achieved by setting background color to the already selected node on the treeViewAdv1_NodeBackgroundPaint event.
Syncfusion.Windows.Forms.Tools.TreeNodeAdv node = this.treeViewAdv1.SelectedNode;
e.Graphics.FillRectangle(new SolidBrush(Color.RosyBrown) , node.TextBounds );
e.Graphics.DrawRectangle(p, node.TextBounds);

2.This can be achieved by cancelling the Before_Expand and Before_Collapse event when the node is disabled.
if ( node.Enabled == false )
{
e.Cancel = true;
}

Herewith I have attached the sample for your reference. Please go through the sample and let me know if you have any queries.
DisabledTree.zip


Thanks,
Murugan P.S

Loader.
Live Chat Icon For mobile
Up arrow icon