To react on an node click, you can use the
TreeView.NodeMouseClick Event[
^].
So in that event you can check which node was clicked and then if the node is the correct one you can use the
RichTextBox.LoadFile Method (String)[
^] to fill the rich text box.
Addition:
To identify the node, you can use for example the
Text[
^] or
Tag[
^] properties.
The event arguments of the NodeMouseClick include the node that was selected. See:
TreeNodeMouseClickEventArgs Class[
^]
Addition 2:
Instead of presuming that the file isn't found check what the exception says. So change the code to:
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
try
{
if (e.Node.Text.Contains("Desert Quest"))
{
string DesertFile = "Z:\\Tibia Tool\\Quests\\DesertQuest.txt";
rchQuests.LoadFile(DesertFile, RichTextBoxStreamType.PlainText);
}
}
} catch (System.IO.FileNotFoundException) {
MessageBox.Show("File not found");
}
catch (System.Exception exception)
{
MessageBox.Show(exception.Message);
}
}
That would give you the exact details also if the exception is something else than file not found.