I was using a CheckedListBox to display a List of Plugin. And i’m using an EventHandler :
private void myCheckedListBox_SelectedIndexChanged(object sender, EventArgs e)
{
myGUIUtilities.SetDescription(myCheckedListBox.SelectedItem, myRichTextBox);
}
To display something …
This is the myGUIUtilities.SetDescription method :
internal static void SetDescription(object p_SelectedObject, RichTextBox p_TextBoxDescription)
{
AbstractEnvChecker l_Plugin = p_SelectedObject as AbstractEnvChecker;
if (l_Plugin != null)
p_TextBoxDescription.Text = l_Plugin.Description;
}
To display my Plugins I just used the CheckedListBox.Items.Add method :
MyCheckedListBox.Items.Add(myPlugin);
That accepts an object as argument …
Now i want to classify my Plugins by cetgories, so i’m using TreeView and TreeNode.
The problem is that the TreeView.Nodes.Add(TreeNode node) accepts only TreeNode Type as argument.
And i can’t actually use the same SetDescription method which needs a Plugin Type to get the Plugin.Description Property …
Is there a way to pass an object to the TreeView.Nodes.Add(TreeNode node) method ?
Or another way to do that ?
Use the
Tagproperty on the tree node to attach an object to it. Then you can pull it back out again later.So you could do this (assuming a
Nameproperty on the plugin object)And then you can rewrite the start of your event handler thus: