Solved

hide TABS if not specified VB.NET 2003/2010

Posted on 2011-03-11
6
560 Views
Last Modified: 2012-05-11
Hi Experts,
I work from a Winform with TabControl + 10 tabs.

my solution now has random tabs on form_load (thanks to previous solution)

Now i want to only limit/show only 5 of them random TABS at any one time. So randomize 10 tabs but only show 5.

Thanks,
Roberto
0
Comment
Question by:RobertoFreemano
  • 4
  • 2
6 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35113417
Try something like:
Public Class Form1

    Private R As New Random
    Private tabs As New ArrayList

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each tp As TabPage In TabControl1.TabPages
            tabs.Add(tp)
        Next

        ShowRandomTabs(5)
    End Sub

    Private Sub ShowRandomTabs(ByVal number As Integer)
        TabControl1.TabPages.Clear()

        Dim temp As New ArrayList
        For Each tp As Object in tabs
            temp.Add(tp)
        Next

        Dim index As Integer
        For i As Integer = 1 to number
            If temp.Count > 0 Then
                index = R.Next(0, temp.Count)
                TabControl1.TabPages.Add(temp(index))
                temp.RemoveAt(index)
            End If
        Next
    End If

End Class

Open in new window

0
 

Author Comment

by:RobertoFreemano
ID: 35114934
Hi Idle_Mind,

I get the following errors:
An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll

Additional information: [Resource lookup failed - infinite recursion detected.  Resource name: Arg_NullReferenceException]


&
There is no source code available for the current location. > 0000004c  mov         edi,dword ptr [eax+4]
0
 

Author Comment

by:RobertoFreemano
ID: 35114983
Those errors are from 2003, but if I put this code into Visual Basic 2010 Express - it works fine.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:RobertoFreemano
ID: 35115019
Hi Idle_Mind,

Do you think I should take a leap of faith in Visual Basic 2010 Express to continue developing in this from now on?
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 110 total points
ID: 35116306
I would...you can make your project target the .Net 2.0 framework which is on most machines.

Not sure what is causing that error in 2003.
0
 

Author Closing Comment

by:RobertoFreemano
ID: 35116355
Thanks Idle_mind ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now