Skale
asked on
Run sub procedure for selected TreeViewNode in vb.net
I've TreeView with checkbox nodes, each node's childnode is representing a sub procedure feature that will perform if this option checked.
I put them in one single button, but i had to check all of them individually but this is a bit hard way to define each of them because it's hard to handle.
Is there anyway like to create a dictionary with this child nodes and sub procedures.
I put them in one single button, but i had to check all of them individually but this is a bit hard way to define each of them because it's hard to handle.
Is there anyway like to create a dictionary with this child nodes and sub procedures.
Public Shared Sub RunCheck(ByVal mdl As IScrModel)
Dim tView As TreeView = GUI.treCheckListMain
Dim dgView As DataGridView = GUI.dgvCheckInfo
dgView.Rows.Clear()
For Each nodeParent As TreeNode In tView.Nodes
For Each nodeChild As TreeNode In nodeParent.Nodes
If nodeChild.Checked = True Then
dgView.Rows.Add(nodeParent.Text, nodeChild.Text, "In queue")
End If
Next
Next
If tView.Nodes.Item("nodBody").Nodes.Item("nodBodyComp").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodBody").Text, tView.Nodes.Item("nodBody").Nodes.Item("nodBodyComp").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Body.ListBodies(mdl, GUI.GetRecursive(GUI.cboCheckBodyComputed_recur.SelectedIndex), GUI.dgvCheckBodyComputed)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodMarker").Nodes.Item("nodMarkerComp").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodMarker").Text, tView.Nodes.Item("nodMarker").Nodes.Item("nodMarkerComp").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Marker.ListMarkers(mdl, GUI.GetRecursive(GUI.cboCheckMarkerPosition_recur.SelectedIndex), GUI.dgvCheckMarkerPosition)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarPa").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSubvar").Text, tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarPa").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Subvar.ListSubvarsPA(mdl, GUI.GetRecursive(GUI.cboCheckSubvarPa_recur.SelectedIndex), GUI.GetSubstr(GUI.cboCheckSubvarPa_substr.SelectedIndex), GUI.GetEval(GUI.cboCheckSubvarPa_eval.SelectedIndex), GUI.dgvCheckSubvarPa)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarHp").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSubvar").Text, tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarHp").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Subvar.ListSubvarsHP(mdl, GUI.GetRecursive(GUI.cboCheckSubvarHp_recur.SelectedIndex), GUI.GetSubstr(GUI.cboCheckSubvarHp_substr.SelectedIndex), GUI.GetEval(GUI.cboCheckSubvarHp_eval.SelectedIndex), GUI.dgvCheckSubvarHp)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarSens").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSubvar").Text, tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarSens").Text)
StyleStatus(rowIndex, "Not Active Yet", Color.Orange)
End If
If tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarMp").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSubvar").Text, tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarMp").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Subvar.ListSubvarsMP(mdl, GUI.GetRecursive(GUI.cboCheckSubvarMp_recur.SelectedIndex), GUI.GetSubstr(GUI.cboCheckSubvarMp_substr.SelectedIndex), GUI.GetEval(GUI.cboCheckSubvarMp_eval.SelectedIndex), GUI.dgvCheckSubvarMp)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarFe").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSubvar").Text, tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvarFe").Text)
StyleStatus(rowIndex, "Not Active Yet", Color.Orange)
End If
If tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvar3d").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSubvar").Text, tView.Nodes.Item("nodSubvar").Nodes.Item("nodSubvar3d").Text)
StyleStatus(rowIndex, "Not Active Yet", Color.Orange)
End If
If tView.Nodes.Item("nodForce").Nodes.Item("nodForce43").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodForce").Text, tView.Nodes.Item("nodForce").Nodes.Item("nodForce43").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Force.ListForce43(mdl, GUI.GetRecursive(GUI.cboCheckForce43_recur.SelectedIndex), GUI.dgvCheckForce43)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodForce").Nodes.Item("nodForce18").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodForce").Text, tView.Nodes.Item("nodForce").Nodes.Item("nodForce18").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Force.ListForce18(mdl, GUI.GetRecursive(GUI.cboCheckForce18_recur.SelectedIndex), GUI.dgvCheckForce18)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodForce").Nodes.Item("nodForce4").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodForce").Text, tView.Nodes.Item("nodForce").Nodes.Item("nodForce4").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Force.ListForce4(mdl, GUI.GetRecursive(GUI.cboCheckForce18_recur.SelectedIndex), GUI.dgvCheckForce18)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodForceOut").Nodes.Item("nodForceOutDist").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodForceOut").Text, tView.Nodes.Item("nodForceOut").Nodes.Item("nodForceOutDist").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
ForceOut.ListForceOutDist(mdl, GUI.GetRecursive(GUI.cboCheckForceOutDist_recur.SelectedIndex), GUI.dgvCheckForceOutDist)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodForceOut").Nodes.Item("nodForceOut43").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodForceOut").Text, tView.Nodes.Item("nodForceOut").Nodes.Item("nodForceOut43").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
ForceOut.ListForceOut43(mdl, GUI.GetRecursive(GUI.cboCheckForceOut43_recur.SelectedIndex), GUI.dgvCheckForceOut43)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodForceOut").Nodes.Item("nodForceOut18").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodForceOut").Text, tView.Nodes.Item("nodForceOut").Nodes.Item("nodForceOut18").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
ForceOut.ListForceOut18(mdl, GUI.GetRecursive(GUI.cboCheckForceOut18_recur.SelectedIndex), GUI.dgvCheckForceOut18)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodForceOut").Nodes.Item("nodForceOut4").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodForceOut").Text, tView.Nodes.Item("nodForceOut").Nodes.Item("nodForceOut4").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
ForceOut.ListForceOut4(mdl, GUI.GetRecursive(GUI.cboCheckForceOut4_recur.SelectedIndex), GUI.dgvCheckForceOut4)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodIfctn").Nodes.Item("nodIfctnBase").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodIfctn").Text, tView.Nodes.Item("nodIfctn").Nodes.Item("nodIfctnBase").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Ifctn.ListIfctn(mdl, GUI.GetRecursive(GUI.cboCheckIfctnBase_recur.SelectedIndex), GUI.dgvCheckIfctnBase)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodComm").Nodes.Item("nodCommSender").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodComm").Text, tView.Nodes.Item("nodComm").Nodes.Item("nodCommSender").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Sender.ListSender(mdl, GUI.GetRecursive(GUI.cboCheckSender_recur.SelectedIndex), GUI.dgvCheckCommSender)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodComm").Nodes.Item("nodCommReceiver").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodComm").Text, tView.Nodes.Item("nodComm").Nodes.Item("nodCommReceiver").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Receiver.ListReceiver(mdl, GUI.GetRecursive(GUI.cboCheckReceiver_recur.SelectedIndex), GUI.dgvCheckCommReceiver)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodExpression").Nodes.Item("nodExpressionCutForce").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodExpression").Text, tView.Nodes.Item("nodExpression").Nodes.Item("nodExpressionCutForce").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Expressions.ListExpressionCutforce(mdl, GUI.GetRecursive(GUI.cboCheckExpressionCutForce_recur.SelectedIndex), GUI.GetSubstr(GUI.cboCheckExpressionCutForce_substr.SelectedIndex), GUI.dgvCheckExpressionCutForce)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodSolve").Nodes.Item("nodSolvePreload").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSolve").Text, tView.Nodes.Item("nodSolve").Nodes.Item("nodSolvePreload").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Preload.ListPreload(mdl, GUI.dgvCheckSolvePreld)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodSolve").Nodes.Item("nodSolveEqui").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSolve").Text, tView.Nodes.Item("nodSolve").Nodes.Item("nodSolveEqui").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Equilibrium.ListEquilibrium(mdl, GUI.dgvCheckSolveEq)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodSolve").Nodes.Item("nodSolveEigen").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodSolve").Text, tView.Nodes.Item("nodSolve").Nodes.Item("nodSolveEigen").Text)
Try
StyleStatus(rowIndex, "Performing", Color.Yellow)
Eigenvalue.ListEigenvalue(Globals.SpckModel, GUI.dgvCheckSolveEva)
StyleStatus(rowIndex, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(rowIndex, "Error Occured", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
End If
If tView.Nodes.Item("nodNaming").Nodes.Item("nodNamingSpck").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodNaming").Text, tView.Nodes.Item("nodNaming").Nodes.Item("nodNamingSpck").Text)
StyleStatus(rowIndex, "Not Active Yet", Color.Orange)
End If
If tView.Nodes.Item("nodNaming").Nodes.Item("nodNamingCad").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodNaming").Text, tView.Nodes.Item("nodNaming").Nodes.Item("nodNamingCad").Text)
StyleStatus(rowIndex, "Not Active Yet", Color.Orange)
End If
If tView.Nodes.Item("nodNaming").Nodes.Item("nodNamingFbi").Checked = True Then
Dim rowIndex As Integer = FindRowDgv(tView.Nodes.Item("nodNaming").Text, tView.Nodes.Item("nodNaming").Nodes.Item("nodNamingFbi").Text)
StyleStatus(rowIndex, "Not Active Yet", Color.Orange)
End If
End Sub
ASKER
Sorry, I don't understand clearly. I have some checks as my tool's feature. User selecting which of the checks will perform (listed on treeview) after user click the run button it's looking for the node is checked or not after that if it's checked it's calling specific procedure for that node
Your actual problem is easily solved by you by looking at the events of your control. Normally tree view controls have events like node clicked, node select etc. Here you have direct access to the node involved.
The rest was a comment about your coding approach involving a lot of guessing: The tree view (UI) should not have any coupling to the executed functionality (logic). It is just the UI for configuring your tool.
The rest was a comment about your coding approach involving a lot of guessing: The tree view (UI) should not have any coupling to the executed functionality (logic). It is just the UI for configuring your tool.
[..] a sub procedure feature [..]In this context this means that you should look into some default approaches in Object Oriented Programming. The patterns I mentioned. Cause depending on these, the problem maybe simply solved by binding your "features" directly to the tree view.
ASKER
How is it possible to bind that one procedure to TreeViewNode? Could you please give an example
E.g.
EDIT: Changed order to support VS designer.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TreeView1.Nodes.Add(DirectCast(New StrategyA("A"), TreeNode))
TreeView1.Nodes.Add(DirectCast(New StrategyA("B"), TreeNode))
TreeView1.Nodes.Add(DirectCast(New StrategyB("C"), TreeNode))
TreeView1.Nodes.Add(DirectCast(New StrategyB("D"), TreeNode))
End Sub
Private Sub TreeView1_DoubleClick(sender As Object, e As EventArgs) Handles TreeView1.DoubleClick
Dim strategy As IStrategy = DirectCast(DirectCast(sender, TreeView).SelectedNode, IStrategy)
strategy.Execute()
End Sub
End Class
Public Interface IStrategy
Sub Execute()
End Interface
Public Class StrategyA
Inherits TreeNode
Implements IStrategy
Public Sub New(AText As String)
Me.Text = AText
End Sub
Public Sub Execute() Implements IStrategy.Execute
MessageBox.Show("A:" & Me.Text)
End Sub
End Class
Public Class StrategyB
Inherits TreeNode
Implements IStrategy
Public Sub New(AText As String)
Me.Text = AText
End Sub
Public Sub Execute() Implements IStrategy.Execute
MessageBox.Show("B:" & Me.Text)
End Sub
End Class
Caveat: this is a really simplified sample.EDIT: Changed order to support VS designer.
ASKER
I think this is what you are wanting to do:
-saige-
Private Sub OnClick(sender As Object, e As EventArgs) Handles Button1.Click
Dim selected = GetChildNodes(tView.Nodes).Where(Function(n) n.Checked AndAlso n.Parent IsNot Nothing)
For Each node In selected
Dim index = FindRowDgv(node.Parent.Text, node.Text)
Try
StyleStatus(index, "Performing", Color.Yellow)
Select Case node.Parent.Name
Case "nodBody"
Body.ListBodies(mdl, GUI.GetRecursive(GUI.cboCheckBodyComputed_recur.SelectedIndex), GUI.dgvCheckBodyComputed)
Case "nodMarker"
Marker.ListMarkers(mdl, GUI.GetRecursive(GUI.cboCheckMarkerPosition_recur.SelectedIndex), GUI.dgvCheckMarkerPosition)
Case "nodSubvar"
Select Case node.Name
Case "nodSubvarPa"
Subvar.ListSubvarsPA(mdl, GUI.GetRecursive(GUI.cboCheckSubvarPa_recur.SelectedIndex), GUI.GetSubstr(GUI.cboCheckSubvarPa_substr.SelectedIndex), GUI.GetEval(GUI.cboCheckSubvarPa_eval.SelectedIndex), GUI.dgvCheckSubvarPa)
Case "nodSubvarHp"
Subvar.ListSubvarsHP(mdl, GUI.GetRecursive(GUI.cboCheckSubvarHp_recur.SelectedIndex), GUI.GetSubstr(GUI.cboCheckSubvarHp_substr.SelectedIndex), GUI.GetEval(GUI.cboCheckSubvarHp_eval.SelectedIndex), GUI.dgvCheckSubvarHp)
Case "nodSubvarMp"
Subvar.ListSubvarsMP(mdl, GUI.GetRecursive(GUI.cboCheckSubvarMp_recur.SelectedIndex), GUI.GetSubstr(GUI.cboCheckSubvarMp_substr.SelectedIndex), GUI.GetEval(GUI.cboCheckSubvarMp_eval.SelectedIndex), GUI.dgvCheckSubvarMp)
Case "nodSubvarSens", "nodSubvarFe", "nodSubvar3d"
StyleStatus(rowIndex, "Not Active Yet", Color.Orange)
Continue For
End Select
Case "nodForce"
Select Case node.Name
Case "nodForce43"
Force.ListForce43(mdl, GUI.GetRecursive(GUI.cboCheckForce43_recur.SelectedIndex), GUI.dgvCheckForce43)
Case "nodForce18"
Force.ListForce18(mdl, GUI.GetRecursive(GUI.cboCheckForce18_recur.SelectedIndex), GUI.dgvCheckForce18)
Case "nodForce4"
Force.ListForce4(mdl, GUI.GetRecursive(GUI.cboCheckForce18_recur.SelectedIndex), GUI.dgvCheckForce18)
End Select
Case "nodForceOut"
Select Case node.Name
Case "nodForceOutDist"
ForceOut.ListForceOutDist(mdl, GUI.GetRecursive(GUI.cboCheckForceOutDist_recur.SelectedIndex), GUI.dgvCheckForceOutDist)
Case "nodForceOut43"
ForceOut.ListForceOut43(mdl, GUI.GetRecursive(GUI.cboCheckForceOut43_recur.SelectedIndex), GUI.dgvCheckForceOut43)
Case "nodForceOut18"
ForceOut.ListForceOut18(mdl, GUI.GetRecursive(GUI.cboCheckForceOut18_recur.SelectedIndex), GUI.dgvCheckForceOut18)
Case "nodForceOut4"
ForceOut.ListForceOut4(mdl, GUI.GetRecursive(GUI.cboCheckForceOut4_recur.SelectedIndex), GUI.dgvCheckForceOut4)
End Select
Case "nodIfctn"
Ifctn.ListIfctn(mdl, GUI.GetRecursive(GUI.cboCheckIfctnBase_recur.SelectedIndex), GUI.dgvCheckIfctnBase)
Case "nodComm"
Select Case node.Name
Case "nodCommSender"
Sender.ListSender(mdl, GUI.GetRecursive(GUI.cboCheckSender_recur.SelectedIndex), GUI.dgvCheckCommSender)
Case "nodCommReceiver"
Receiver.ListReceiver(mdl, GUI.GetRecursive(GUI.cboCheckReceiver_recur.SelectedIndex), GUI.dgvCheckCommReceiver)
End Select
Case "nodExpression"
Expressions.ListExpressionCutforce(mdl, GUI.GetRecursive(GUI.cboCheckExpressionCutForce_recur.SelectedIndex), GUI.GetSubstr(GUI.cboCheckExpressionCutForce_substr.SelectedIndex), GUI.dgvCheckExpressionCutForce)
Case "nodSolve"
Select Case node.Name
Case "nodSolvePreload"
Preload.ListPreload(mdl, GUI.dgvCheckSolvePreld)
Case "nodSolveEqui"
Equilibrium.ListEquilibrium(mdl, GUI.dgvCheckSolveEq)
Case "nodSolveEigen"
Eigenvalue.ListEigenvalue(Globals.SpckModel, GUI.dgvCheckSolveEva)
End Select
Case "nodNaming"
Select Case node.Name
Case "nodNamingSpck", "nodNamingCad", "nodNamingFbi"
StyleStatus(rowIndex, "Not Active Yet", Color.Orange)
Continue For
End Select
End Select
StyleStatus(index, "Finished", Color.Green)
Catch ex As Exception
StyleStatus(index, "Error Occurred", Color.Red)
Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
End Try
Next
End Sub
GetChildNodes is an extension in a Module -
Module Extensions
<Extension>
Public Iterator Function GetChildNodes(tree As TreeNodeCollection) As IEnumerable(Of TreeNode)
For Each node In tree.OfType(Of TreeNode)
Yield node
For Each child In GetChildNodes(node.Nodes)
Yield child
Next
Next
End Function
End Module
That being said, ste5an's recommendation is the preferred route I would take. I understand that you have a tree view that you already made in the designer. But using the strategy pattern as proposed by ste5an would simplify this greatly.-saige-
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for your helps and contributions. i'm really appreciate for your helps.
From the OO perspective:
Take a look at the template and the strategy pattern first. Also take look at the command and the chain of responsibility pattern.