tags:

views:

36

answers:

1

Hi,

Is there a way I can keep the text of a Parent node but remove the link? The treeview parent node is used just as a header, no navigation.Any help would be great.Thanks.

private void BindNodes(string PtID)
{
if (PtID != "")
{
int PatientID = Convert.ToInt32(PtID);
DBConnection dbObj = new DBConnection();
if (Session["Activepatient"] != null)
{
string[] SubChild = new string[4];
SubChild[0] = "Demographics";
SubChild[1] = "Medication Reviews";
SubChild[2] = "Drug Testing & Monitoring";
SubChild[3] = "Other Program";

                TreeNode oTrParent = new TreeNode();  
                //trv_patient.ParentNodeStyle = "None";
                //oTrParent.SelectAction.Style.Add("display", "none");
                TreeNode oTrSubChild1;
                TreeNode oTrSubChild;
                for (int i = 0; i < 4; i++)
                {
                    oTrSubChild1 = new TreeNode();
                    oTrSubChild1.Text = SubChild[i];
                    if (i == 1)
                    {
                        PatientInfoCollection patientCollection = new PatientInfoCollection();
                        patientCollection = dbObj.GetMedicationReviews(PatientID);
                        foreach (PatientInfo au in patientCollection)
                        {
                            oTrSubChild = new TreeNode();
                            PatientInfo Patient = new PatientInfo();
                            oTrSubChild.Text = au.DateRcvd.Value.ToString("MM-dd-yyyy")
                            oTrSubChild.Target = au.ReviewId.ToString();
                            oTrSubChild1.ChildNodes.Add(oTrSubChild);
                        }
                        oTrSubChild = new TreeNode();
                        oTrSubChild.Text = "Add Medication Review";
                        oTrSubChild.Target = "New";
                        oTrSubChild1.ChildNodes.Add(oTrSubChild);
                    }
                    trv_patient.Nodes.Add(oTrSubChild1);
                }
            }
        }
    }
A: 

I'm not sure if I understand what you want. Assuming that it's WinForms and that you just want to disable the ability to select the root node in a TreeView you could just handle the BeforeSelect event of the TreeView and then have the following code:

if (e.Node.Parent == null)
    e.Cancel = true;
ho1
Hi ho1,Thanks for your reply. There is no event called "BeforeSelect" for treeview. I am not using windows forms. Which event should be raised to make the parent node as non-clickable.
karthik