PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Diabling Tabpage

Reply

Diabling Tabpage

 
Thread Tools Rate Thread
Old 10-12-2003, 02:06 AM   #1
Raju Shrestha
Guest
 
Posts: n/a
Default Diabling Tabpage


I tried to disable a tabpage by using tp.Enabled = False. It disables
all the controls contained on that tabpage but still I can move focus to
that tabpage which is not as expected. What is the workaround of this
problem?
Appreciate for the answer.
Thanks

Raju Shrestha

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  Reply With Quote
Old 10-12-2003, 08:57 AM   #2
Claes Bergefall
Guest
 
Posts: n/a
Default Re: Diabling Tabpage

Try this:

Public Class TabControlEx
Inherits TabControl

Private Const WM_LBUTTONDOWN As Integer = &H201
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_LBUTTONDOWN Then
Dim pt As New Point(m.LParam.ToInt32)
Dim index As Integer
For index = 0 To Me.TabPages.Count - 1
If GetTabRect(index).Contains(pt) Then
If TabPages(index).Enabled Then
MyBase.WndProc(m)
End If
Exit Sub
End If
Next
End If
MyBase.WndProc(m)
End Sub

Protected Overrides Sub OnKeyDown(ByVal ke As
System.Windows.Forms.KeyEventArgs)
Dim currentIndex As Integer = Me.SelectedIndex
Dim index As Integer
If ke.KeyCode = Keys.Left AndAlso Not (ke.Alt AndAlso Not
ke.Control) Then
For index = currentIndex - 1 To 0 Step -1
If TabPages(index).Enabled Then
Me.SelectedIndex = index
Exit For
End If
Next
ke.Handled = True
ElseIf ke.KeyCode = Keys.Right AndAlso Not (ke.Alt AndAlso Not
ke.Control) Then
For index = currentIndex + 1 To TabPages.Count - 1
If TabPages(index).Enabled Then
Me.SelectedIndex = index
Exit For
End If
Next
ke.Handled = True
End If
MyBase.OnKeyDown(ke)
End Sub
End Class

/claes

"Raju Shrestha" <rajustha2000@yahoo.com> wrote in message
news:uDhw9IsvDHA.2460@TK2MSFTNGP10.phx.gbl...
> I tried to disable a tabpage by using tp.Enabled = False. It disables
> all the controls contained on that tabpage but still I can move focus to
> that tabpage which is not as expected. What is the workaround of this
> problem?
> Appreciate for the answer.
> Thanks
>
> Raju Shrestha
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



  Reply With Quote
Old 10-12-2003, 09:14 AM   #3
Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
Default Re: Diabling Tabpage

* Raju Shrestha <rajustha2000@yahoo.com> scripsit:
> I tried to disable a tabpage by using tp.Enabled = False. It disables
> all the controls contained on that tabpage but still I can move focus to
> that tabpage which is not as expected. What is the workaround of this
> problem?


This code shows how to detect when the selected tab changes:

<http://www.google.de/groups?selm=hxAg9.261485%24kp.887854%40rwcrnsc52.ops.asp.att.net>

Maybe you can use it.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off