Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TabControl Question... 4

Status
Not open for further replies.

pzmgmb

Programmer
Apr 2, 2003
115
0
0
US
I know i can do this in VB .NET with the TabControl:

Code:
Me.TabControl1.TabPages(0).Enabled=False

Why can't i do this?

Code:
Me.TabControl1.TabPages("Inventory").Enabled=False

Could anybody help me to achieve this?
 
Hmmm, interesting one - it appears a tabcontrol page does not have an enabled property and therefore you could not possible perform this task. However, I'm sure there must be a way to do it knowing the complexity and functionality of .net - just haven't found it yet !!!!

OK, this doesn't really help, so as an interim 'get round', why not programatically hide and unhide the tabpage -


eg

If condition = True Then
me.TabControl1.TabPages.Remove(TabPage1)
else
me.TabControl1.TabPages.Add(TabPage1)
End If


Removing and adding a tabcontrol page does not affect the controls on the page itself.


Hope this helps,
Paul
 
TabPages only accepts an integer index so to get around it you could use the following method

Code:
Private Function GetTabPage(ByVal Name As String) As TabPage
        Dim page As TabPage
        For Each page In TabControl1.TabPages
            If page.Name = Name Then
                GetTabPage = page
                Exit Function
            End If
        Next
    End Function

To call it ...
Code:
GetTabPage("TabPage1").Enabled = False
 
Haven't tried your code, but if it works, good on ya!!

Just for your info, the code I posted will accept the tab page name and not just the array/integer reference
 
jubble,
Thanks for the code... good idea... i just thought there would be a more eloquent way in .NET. Guess Not. [thumbsup2]
 
You're right .... there should be one tucked away somewhere but I haven't found it yet.
Sometimes there are some methods and properties that don't show up in intellisense so it's worth trying the name of a method or different parameter types just to see if it hasn't been exposed properly.
 
Sometimes there are some methods and properties that don't show up in intellisense so it's worth trying the name of a method or different parameter types just to see if it hasn't been exposed properly.

If you're using visual studio .Net 2k2 do the following:

Tools -> Options -> Text Editor -> Basic -> General

Uncheck the "Hide Advanced Members" check box.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
[banghead]
 
Nice one!

Thanks for the tip.

You mentioned 2k2...it's also checked by default in 2k3.
 
patch?!

I'm getting so bloody concerned with networking patches that I totally missed that one.

Was it provided with MSDN?
 
I've still missed it ... there seems to be very little info regarding a VS.Net 2003 Patch/Service Pack.
 
Have a
star.gif
from me Rick as that has been bugging me for ages (there is a IsStartupScriptRegistered method in ASP.NET that I could use but it never appeared as intellisense and I couldn't figure out why!)

Thanks again
Mark

----------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top