4
Answers

Mouse over on Root node of a tree view

Chaitanya

Chaitanya

13y
2.7k
1
I am having a treeview with one root node . I have written MouseHoverEvent as follows

private void tvwACH_NodeMouseHover(object sender, TreeNodeMouseHoverEventArgs e)
    {

        string strFile = string.Empty;
        if (e.Node.Parent.Text == "FileHeader")
        {
            strFile = e.Node.ToString();

            string str = strFile.Substring(10);
            StringComparison compareType = StringComparison.InvariantCultureIgnoreCase;
            string fileName = Path.GetFileNameWithoutExtension(str);
            string extension = Path.GetExtension(str);
            if (extension.Equals(".txt", compareType))
            {

                StringBuilder osb = new StringBuilder();
                objFileHeader.getFileHeader(str, out osb);
                e.Node.ToolTipText = Convert.ToString(osb);
            }
        }

But if i had my mouse on the root node i am getting an error as null exceptio handled. If i had my mouse hover the root node nothing should be happened. Can any one help me please.

Answers (4)