Hi,
I want to write code to manage standard (or generic) forms in Windows
Forms (i don't know the correct word) like that :
- a base form in a class : frmBase with some controls inside it :
labels, textbox, buttons ..
- many forms, each in a class : frmCustomer, frmSupplier, frmProduct ...
Each form inherits from frmBase and have specific controls (labels,
textbox, buttons ..) more inherited controls of frmBase.
Each class (frmBase, frmCustomer ..) is in a file (frmBase.vb,
frmCustomer.vb ..).
I want to access each controls (specific and inherited) as control array
(i know there are not now control arrays in .net).
So i want use the code that Cor Ligthert suggests :
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
doset(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
AddHandler ctr.LostFocus, AddressOf meLostFocus
AddHandler ctr.GotFocus, AddressOf meGotFocus
' and many other AddHandler
doSet(ctr)
Next
End Sub
Private Sub meLostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
' here code to manage LostFocus
End Sub
Private Sub meGotFocus(ByVal sender As Object, _
ByVal e As System.EventArgs)
' here code to manage GotFocus
End Sub
...
I don't want to put all the code in each form but to have only once this
code.
Now my questions :
1) is it possible to put this code only in frmBase ?
For that, is it possible to access in frmBase at the specific controls
of derived forms ? by reflection ?
by polymorphism ?
2) can the address following the keyword Addressof to be in another
class ? in the same project ?
in an another project of the solution ?
Many thanks for your help, ideas, links to articles ..
Best Regards,
Dominique
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!