Good morning everyone
i call 2 method from a class i assume it as "hiddenButton" class
one is to set the visibility of button
another method is the hide the button
i already initialize the button and hide it when the program has run
to show the button from hiddenButton
i have to click on the button from the main form and i assume it as "show button"
if i click on the "show button", it will actually hide away the button
without removing the eventhandler, when i click on the "show button" it should be show and hide my button
but my button from "hiddenButton" class only show and hide once, then it doesn't work anymore.
I already try my eventhandler by using messagebox, when i click on the "show button", it actually pop up the messagebox without any problem
so i wonder why the button of "hidden button" only show and hide once then it doesn't work
is that because my button was actually set on the same location with other object on the form?
What I have tried:
from main code
<br />
dim _hiddenButton as new hiddenButton<br />
_hiddenButton.initButton(form1) 'add button to form 1<br />
dim _otherElement as new otherElement<br />
_otherElement.initElement(from1) 'add other element to form1<br />
dim _button as button = new button<br />
with _button<br />
.text = "show button"<br />
addhandler .mouseclick, addressof bmClicked<br />
end with<br />
form1.controls.add(_button)<br />
<br />
private sub bmClicked(byval sender as object, byval e as eventargs)<br />
dim _button as button = sender<br />
<br />
with _button<br />
if .text = "Show Me" then<br />
.text = "Hide me"<br />
hiddenButton.buttonShow()<br />
else if .text = "Hide Me" then<br />
.text = "Sow Me" then<br />
hiddenButton.hideButton()<br />
end with<br />
end sub<br />
code from hiddenButton Class
<pre lang="vb">
private shared _button as button
public sub initButton(byval formName as form)
_button = new button
with _button
.text = "hello code project"
.size = new size(100, 100)
.location = new point(30,30)
.visible = false
end with
formName.controls.add(_button)
end sub
public shared sub buttonShow()
_button.visible = true
end sub
public shared sub buttonHide()
_button.visible = false
end sub
class from otherElement
private _backgroundPanel as panel
public sub initElement(byval fromName as form)
_backgroundPanel = new panel
with _backgroundpanel
.backgroundcolor = color.black
.size = new size (screen.primaryscreen.bounds.width, screen.primaryscreen.bounds.height)
.location = new point(0,0)
end with
formName.controls.add(_background)
end sub