Fire AfterSelection event
-
Hello, i have a tree view ,were an After Selection event occurs after selecting a node. i also have a function called refresh which refreshes the tree View by building it from scratch. the problem is that when the refresh is made, the selected node is not changing, which is fine, but the after Select event is not fired, which is not fine at all (since this event retrieves necessary data). my question is: how (if possible) can i fire an after Selection event without changing my selection. attached is relevant code Thanks
private void tvwProject_AfterSelect(object sender, TreeViewEventArgs e)
...//this code mainly constructs the tree View
private void refreshProjectTree()
{
if (isProject)
{
BLFunctions.BuildProjectTree(tvwProject);
BLFunctions.ExpandNode(tvwProject, tvwProject.Nodes[0]);
}
else
{
BLFunctions.BuildSchemaTree(tvwSchema);
}
} -
Hello, i have a tree view ,were an After Selection event occurs after selecting a node. i also have a function called refresh which refreshes the tree View by building it from scratch. the problem is that when the refresh is made, the selected node is not changing, which is fine, but the after Select event is not fired, which is not fine at all (since this event retrieves necessary data). my question is: how (if possible) can i fire an after Selection event without changing my selection. attached is relevant code Thanks
private void tvwProject_AfterSelect(object sender, TreeViewEventArgs e)
...//this code mainly constructs the tree View
private void refreshProjectTree()
{
if (isProject)
{
BLFunctions.BuildProjectTree(tvwProject);
BLFunctions.ExpandNode(tvwProject, tvwProject.Nodes[0]);
}
else
{
BLFunctions.BuildSchemaTree(tvwSchema);
}
}Factor the code out to a method you call at the end of your refresh method.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Factor the code out to a method you call at the end of your refresh method.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Hi Christian, could you be more specific ? i couldn't understand what you mean by your answer.
It's painfully obvious. you have some code inside an event, that you need to run in a situation where the event does not fire. So take this code, move it to a new method, and then call this method from your event, and from the method which you were hoping would fire this event. And buy a basic book like 'Code Complete', and read it.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
It's painfully obvious. you have some code inside an event, that you need to run in a situation where the event does not fire. So take this code, move it to a new method, and then call this method from your event, and from the method which you were hoping would fire this event. And buy a basic book like 'Code Complete', and read it.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Ok mr.Graus so if you say so, how would i get the TreeViewEventArgs if im calling a method where no such args are sent to it ?!?!?!?