Solved

Enabling or Disabling a TabPage in VB.Net

Posted on 2003-11-10
5
3,069 Views
Last Modified: 2007-12-19
Hi,
I want to Enanble or disable a Tabpage.
as we do in VB6 where whe can disable a tab from entering
by disabling that particular Tab.
Is there any possibility like that in VB.net
coz i need it for security reasons.
According to the user rights i have to enable or disable the Tabs.
It would be wonderful if you could help me in this.
 
I tried with the SelectedIndexChanged Event of the Tabstrip.
But it is not working fine.
Expecting your  reply
 
With regards
Karthik
0
Comment
Question by:karthikwaits4u
5 Comments
 
LVL 19

Expert Comment

by:Desp
ID: 9720547
0
 

Author Comment

by:karthikwaits4u
ID: 9721105
Dear Desp,
Thanx for the advice.
But I Don't want to remove the Tab.
Because we have three modes (Add,Modify,View)
In the view mode the user can access all the Tabs in the TabControl
But if he clicks the modify or Add Button he must not be able to access
any other Tab. b'coz he has to complete the Add/ Modify operation
first on this TabPage.
So please help me.
I tried this code
TabRepOffice.TabPages(1).Enabled=false
This code actually works fine. It disables all the controls in TabPage1
but doesnot disable the TabPage.
So please help me in this issue
Regards
Karthik
0
 

Expert Comment

by:sunny1510
ID: 9725035
hi karthik,

                   u could use the selectedindex changed event  here.......it is called whenever you change tabs....so in that event handler check if all the controls in the current tab pass the validation........if it does then allow tab change or else stay on the current tab...
0
 
LVL 3

Accepted Solution

by:
sony1464 earned 50 total points
ID: 9733785
Hello Karthik,

I put together a small example ......here i have two tab pages with a text box on the first tab page.......only if the validation passes on the first tab page  i allow the user to change tabs.......u could try something similar to this for u r app....

 Private currentTab As Integer = 0
 Private errorControl As Control = Nothing
Private Sub HandleTabChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
            If Not IsNothing(errorControl) Then
            TabControl1.SelectedIndex = currentTab
        Else
            Dim success As Boolean = True
            If currentTab >= 0 Then
                If TextBox1.Text = "vb" Then
                    success = True
                Else
                    success = False
                End If

            End If
            If success Then
                currentTab = TabControl1.SelectedIndex
            Else
                TabControl1.SelectedIndex = currentTab
            End If
        End If
    End Sub
0
 

Author Comment

by:karthikwaits4u
ID: 9737485
Thanks Sony 1464
That really fixed my problem
Thanx for ur Kind Support
With Regards
Karthik
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Single Form 8 42
How to join on ID, with prefix? 15 59
Help with preventing downloading a zip file 10 37
Problem with SelectList in .NET MVC application 1 17
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
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 …

809 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