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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

treeViewAdv node enable/disable

Thread ID:

Created:

Updated:

Platform:

Replies:

51888 Nov 16,2006 02:07 AM UTC Nov 20,2006 09:05 PM UTC Windows Forms 6
loading
Tags: Tools
Rasesh Chauhan
Asked On November 16, 2006 02:07 AM UTC

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

Administrator [Syncfusion]
Replied On 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

Malarvizhi [Syncfusion]
Replied On 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.

Rasesh Chauhan
Replied On 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.

Malarvizhi [Syncfusion]
Replied On 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.

Rasesh Chauhan
Replied On 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

Murugan [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;