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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unable not selected tab in tab control 1

Status
Not open for further replies.

zouzouna

Programmer
Apr 11, 2010
6
GR
Hello, I am new member there, I am using Visual Basic.net 2003 version and I am facing a problem.
Well I have a tab control on a form with two tabs.
I have a button in each tab and I want when the user clicks on it to be unable to select the other tab in the form, not the current tab.

I was trying something like that with no effect of course.

x = LoginTabCntrl.TabIndex + 1
LoginTabCntrl.TabPages.Item(x).Hide()

So, can anyone help me??? I hope to find a way to do that.
Any help will be much appreciated.

Thank you so much
in advanced.
 
What I would do is create a subroutine that
1) sets all controls on any tab that is affected by the button click to enable=false

2) Set those same controls visible = false.

3) Set up a second routine that would re-enable, and make visible the controls on all other tabs as needed.

Basically, you treat a tab control just like any other form and/or control.

Look here for some advice:
And finally, do a google search for vb.net tab control (or similar key words).
 
Thank you so much, for your reply.
I finally tried this and it seams to work for me.

Dim OppositeTabIndx As Integer
OppositeTabIndx = LoginTabCntrl.SelectedIndex + 1
LoginTabCntrl.SelectedIndex = OppositeTabIndx LoginTabCntrl.TabPages.Remove(LoginTabCntrl.SelectedTab)
 
You might also want to take a look at the TabControl "SelectedIndexChanged". You could place code in there to return to the page you want. I use this to prevent users from entering certain pages when they are in my "Edit" mode.

Auguy
Northwest Ohio
 
I was searching an event like that Auguy, thank you so much, what kind of code could you place there to prevent users from entering certain pages when they are in "edit" mode. Can you give an example please?
 
Maybe something like that???
where ChckSaveBtnPressed is a boolean variable indicates that the button has pressed.

Private Sub LoginTabCntrl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginTabCntrl.SelectedIndexChanged

OppositeTabIndx = LoginTabCntrl.SelectedIndex
If ChckSaveBtnPressed = True Then
If OppositeTabIndx = LoginTabCntrl.TabCount - 1 Then
OppositeTabIndx = LoginTabCntrl.SelectedIndex - 1
LoginTabCntrl.SelectedIndex = OppositeTabIndx
End If
End If

End Sub
 
Here it is
Code:
' Keep detail page displayed
If EditMode And Me.TabControl1.SelectedIndex = TabNo_ListPage Then
  Me.TabControl1.SelectedIndex = TabNo_DetailPage
Else
  ...
Endif
TabNo_ListPage and TabNo_DetailPage are established in the form's declaratoions section. Watch out for other events that might fire as you return to the desired page. I sometimes "refresh" the data for the grid on the "List" tab of my form in this code before the "List" tab is displayed.

Auguy
Northwest Ohio
 
Do you mean the data interaction of a database when you refer grid or list? Does EditMode is established in the form's declarations section? Sorry for my question, I am new to programming.
 
Sorry if I misled you. I was referring to a boolean value that I call my "EditMode". This value is set/reset by the program when the user clicks one of my edit/save/undo buttons.

Auguy
Northwest Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top