|
hi all, i created a Class Library project.. added a procedure that loops thru all the controls in a form. ----------- Public Shared Sub Check(frm as Form) Dim ctl As Control = frm.GetNextControl(frm, True) Do until ctl Is Nothing 'Some codes here. ctl = frm.GetNextControl(ctl, True) Loop End Sub ----------- this works okay but i'm wanting to not pass an argument form in the procedure. instead, i want the procedure to get the form that invoked it. something like... ----------- Imports System.Reflection Public Shared Sub Check() Dim objMB As MethodBase Dim objType As Type objMB = MethodBase.GetCurrentMethod objType = objMB.DeclaringType Dim objForm As Object = Activator.CreateInstance(Type.GetType(objType.Assembly.GetName.Name.ToString & "." & objType.Name.ToString)) Dim frm As Object = Directcast(objForm, Form) Dim ctl As Control = frm.GetNextControl(frm, True) Do until ctl Is Nothing 'Some codes here. ctl = frm.GetNextControl(ctl, True) Loop End Sub ----------- the above code is just a sample of what i'm trying to achieve... it's not a working code. can anyone help me? thanks |