Valamas
You cannot when you use both
Cor
>Hi All
>
[quoted text clipped - 19 lines]
>
>regards, valamas
I must be missing something because the obvious DRY (Do not
Repeat Yourself) solution is:
Public Overloads Sub SetNodeImageIndex( _
ByVal oNode As System.Windows.Forms.TreeNode, _
ByVal ImageIndex As String _
)
' Delegate actual work to one common method
SetNodeImageIndexCommon(oNode, CInt(ImageIndex))
End Sub
Protected Overloads Sub SetNodeImageIndex( _
ByVal e As System.Windows.Forms.TreeViewCancelEventArgs, _
ByVal ImageIndex As Long _
)
' Delegate actual work to one common method
SetNodeImageIndexCommon(e.Node, CInt(ImageIndex))
End Sub
Private Sub SetNodeImageIndexCommon( _
ByVal oNode As System.Windows.Forms.TreeNode, _
ByVal ImageIndex As Integer _
)
' Do actual work in only one place
oNode.ImageIndex = ImageIndex
oNode.SelectedImageIndex = ImageIndex
End Sub
Or even
Public Overloads Sub SetNodeImageIndex( _
ByVal oNode As System.Windows.Forms.TreeNode, _
ByVal ImageIndex As String _
)
' Do actual work in only one place
oNode.ImageIndex = CInt(ImageIndex)
oNode.SelectedImageIndex = CInt(ImageIndex)
End Sub
Protected Overloads Sub SetNodeImageIndex( _
ByVal e As System.Windows.Forms.TreeViewCancelEventArgs, _
ByVal ImageIndex As Long _
)
' Delegate actual work to one common method
SetNodeImageIndex(e.Node, CStr(ImageIndex))
End Sub
'Any fool can write code that a computer can understand.
Good programmers write code that humans can understand.'
Martin Fowler,
'Refactoring: improving the design of existing code', p.15