User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 391,609 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,620 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 313 | Replies: 2 | Solved
Reply
Join Date: Jun 2008
Posts: 16
Reputation: tirso is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
tirso tirso is offline Offline
Newbie Poster

forms control

  #1  
Jun 21st, 2008
In my forms I have a tab control containing two pages, in tabpage1 (list view) tabpage2 (gridview) and a several buttons. my problem now is how to know that if the user hit a button then locate the active control or tabpage eaither tabpage1 or tabpage2. I intent that the user chosen either the tabpage1 or tabpage2 then click the ok button, after click the ok button then I want to know the previous active control or tabpage. Please help me

I am a newbie with this environment, I am using vb 2005. I have no other resources but only this forums. I have read some help and tutorial but sometimes very hard to understand

Thanks a lot
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2002
Location: West Virginia
Posts: 368
Reputation: waynespangler is on a distinguished road 
Rep Power: 6
Solved Threads: 34
waynespangler waynespangler is offline Offline
Posting Whiz

Re: forms control

  #2  
Jun 21st, 2008
Use a variable to keep track of the last tab clicked. I used a tab control with two tabs, a button on each page and a button on the form. Here is the code:
Public Class Form1
    Dim TabPage As Integer = 1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Select Case TabPage
            Case 1
                Button2.PerformClick()
            Case 2
                Button3.PerformClick()
        End Select
    End Sub


    Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        Dim tc As TabControl = sender
        Dim txt As String = tc.SelectedTab.ToString
        If txt.IndexOf("{TheFirstPageText") > -1 Then
            TabPage = 1
        Else
            TabPage = 2
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        MessageBox.Show("Button 2 clicked")
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        MessageBox.Show("Button 3 clicked")
    End Sub

End Class
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote  
Join Date: Jun 2008
Posts: 16
Reputation: tirso is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
tirso tirso is offline Offline
Newbie Poster

Re: forms control

  #3  
Jun 22nd, 2008
hi waynes, thank you so much for your immediate replied. This will help too much for me as a beginner.

Cheers.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 12:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC