CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    41

    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

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    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.

  3. #3
    Join Date
    Mar 2004
    Posts
    41

    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

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: issue with callbyname with controls in tabs

    Mark your thread resolved please

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured