Saturday, January 16, 2010

How can you make a dynamic control in VB.net invisible after displaying it once ?

i am creating 10 panels inside a for loop. when i call this loop again i need the panels made before tobe gone or invisible and a new set of panels should be visible to the user. Can anyone help with me?How can you make a dynamic control in VB.net invisible after displaying it once ?
Try this:





Dim bShowControls As Boolean = True





Private Sub ShowControls()


Dim i As Integer





For i = 0 to 9


myControls(i).Visible = bShowControls


Next


bShowControls = False








End Sub





Since bShowControls is a module level variable, its state will persist and your controls will be shown once. If your code is inside a class then delcare and initialize bShowControls inside the class.

No comments:

Post a Comment