VB.net - Checking for the instance of a control
-
-
I am trying to find out how to check to see if a control exists (such as a listbox). If it does, then the program wouldn't do anything, if it doesn't, then the program would create it. Does anyone know how to do this or can point me in the right direction?
Why don't you use a variable to hold the reference to the listbox and set it to
Nothing
whenever it isn't instantiated?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles] -
I am trying to find out how to check to see if a control exists (such as a listbox). If it does, then the program wouldn't do anything, if it doesn't, then the program would create it. Does anyone know how to do this or can point me in the right direction?
You should really be checking for the existance of the piece of data that triggered the control being created, not checking for the control itself.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007