Make child form label invisible
-
Hello, I am facing the problem in accessing the child form control property. In my application depend upon certain condition , i have to hide some controls of some child forms. I have created a module wherein writen a Public procedure to hide one of the child form's control and call the procedure in MDI forms load event. But, Whenver i am executing the application , code doen't take any effect and control still remain s visible. Here is the code: Module Mod1 Public sub HideControl(byval var as boolean) if var=false then Dim frmName As frmSearch If frmName Is Nothing Then frmName = New frmSearch frmName.label1.Visible = false End If endif end sub end module This is first way i tried. Second way : I have defined a property for accessing the form instance and with this instance accessing the control as below: ''' global variables Private Shared SearchInstance As frmSearch Private Shared bSearchInit As Boolean Public Shared Property DefInstance() As frmSearch Get If SearchInstance Is Nothing OrElse SearchInstance.IsDisposed Then bSearchInit = True SearchInstance = New frmSearch bSearchInit = False End If DefInstance = SearchInstance End Get Set(ByVal Value As frmSearch) SearchInstance = Value End Set End Property Using this property accessing cotrol and setting its property in module as: frmSearch.DefInstance.label1.Visible = false None of the these codes seems to be working. when i open that child form i still found that label visible. Please anyone who knows the answer let me know, how to do it. Please Give some code , its urgent as i am unable to proceed further. Any help will be highly appreciated. Thanks
-
Hello, I am facing the problem in accessing the child form control property. In my application depend upon certain condition , i have to hide some controls of some child forms. I have created a module wherein writen a Public procedure to hide one of the child form's control and call the procedure in MDI forms load event. But, Whenver i am executing the application , code doen't take any effect and control still remain s visible. Here is the code: Module Mod1 Public sub HideControl(byval var as boolean) if var=false then Dim frmName As frmSearch If frmName Is Nothing Then frmName = New frmSearch frmName.label1.Visible = false End If endif end sub end module This is first way i tried. Second way : I have defined a property for accessing the form instance and with this instance accessing the control as below: ''' global variables Private Shared SearchInstance As frmSearch Private Shared bSearchInit As Boolean Public Shared Property DefInstance() As frmSearch Get If SearchInstance Is Nothing OrElse SearchInstance.IsDisposed Then bSearchInit = True SearchInstance = New frmSearch bSearchInit = False End If DefInstance = SearchInstance End Get Set(ByVal Value As frmSearch) SearchInstance = Value End Set End Property Using this property accessing cotrol and setting its property in module as: frmSearch.DefInstance.label1.Visible = false None of the these codes seems to be working. when i open that child form i still found that label visible. Please anyone who knows the answer let me know, how to do it. Please Give some code , its urgent as i am unable to proceed further. Any help will be highly appreciated. Thanks
I think you might be making things a bit to complicated. This is how I would do it: in the mdi set a property (shared one) to true or false (for further referance: b1) then when you open the child forms in the contstructor (or load) check this property and set you're controls to visible or not. child.label1.visible= mdi.b1(shared property) ... if you also need to change the visibility of you're child forms while they already exist you can run thru them everytime the property is set: public property b1 as boolean get return ... end get set (value as boolean) for each frm as form in mdi.MdiChildren if frm.gettype.equals(gettype(frmsearch)) then dim f as form = frm f.label1.visible = 'true or false end if next end set hope this helps
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.