issue with callbyname with controls in tabs
Using VB.NET 08
I'm using the following code which loops through a datagridview and makes the buttons found in the list visible
HTML Code:
CallByName(Me.Controls("btn_" & list.Rows(J).Cells(1).Value()), "Visible", CallType.Set, True)
This code works fine with no issue with the buttons on on the form. However when I placed the buttons in to a tabcontrol on the same form I get the following error:
Object variable or With block variable not set.
Does this error relate to the way CallByName calls the button handler and that its different to they way you could otherwise produce the same result using
HTML Code:
button1.visible=true
Any Input would be great as I really can't seem to find a solution to this on the web (tho im sure its out there :P )
Cheers - Tom
Re: issue with callbyname with controls in tabs
Your issue is that when you put the buttons on the TabControl, they are no longer on the form. so the part that is causing the issue is...
Me.Controls(....
Basically, you buttons are no in the me.controls collection. They are part of the TabPage Control collection.
You will have to iterate through the controls on the tabpage to get the reference to the button you want.
Re: issue with callbyname with controls in tabs
Thanks Sotoasty,
After hearing that it now seems obvious heres a similar issue that some one else has had on code guru:
http://www.codeguru.com/forum/showthread.php?t=493073
I should be right from here thanks again for your time
- Tom
Re: issue with callbyname with controls in tabs
Mark your thread resolved please