cancel change in tab selected

  • Thread starter Thread starter dennist
  • Start date Start date
D

dennist

Is there an event in which I can cancel a change in the
tab selected. I just spent a half-hour with the
documentation and couldn't figure it out.

I must say that the help in vs.net is less direct and
practical than the help in vs6.

Do I have to go to a third party product, such as
infragistics, in order to get this rather basic and
crucial choice? I hope not.

dennist
 
Hi dennist,
I've also searched the documention, to my knowledge,I'm afraid the tab
page control doesn't provide this feature,
perhaps, you may handle all the ???Changed (TextChanged, ValueChanged etc)
events in your tab page, and save these values by your self, Please let me
konw, if you still have problem ,thanks!
Kind regards,

Ying-Shen Yu [MSFT]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "dennist" <[email protected]>
| Sender: "dennist" <[email protected]>
| Subject: cancel change in tab selected
| Date: Fri, 15 Aug 2003 02:30:38 -0700
| Lines: 12
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNjD+M7Wklfh0f5QO+Htrbi/CFicw==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:50339
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Is there an event in which I can cancel a change in the
| tab selected. I just spent a half-hour with the
| documentation and couldn't figure it out.
|
| I must say that the help in vs.net is less direct and
| practical than the help in vs6.
|
| Do I have to go to a third party product, such as
| infragistics, in order to get this rather basic and
| crucial choice? I hope not.
|
| dennist
|
 
The Win32 control provides a notification for this
but it isn't exposed through .NET. You'll need
to override TabControl to handle it. Try this:

Imports System.Runtime.InteropServices
Public Class TabControlEx
Inherits TabControl

Public Const TCN_FIRST As Integer = 0 - 550
Public Const TCN_SELCHANGING As Integer = TCN_FIRST - 2
Public Const WM_USER As Integer = &H400
Public Const OCM__BASE As Integer = WM_USER + &H1C00
Public Const OCM_NOTIFY As Integer = OCM__BASE + WM_NOTIFY

<StructLayout(LayoutKind.Sequential)> Public Structure NMHDR
Public hwndFrom As IntPtr
Public idFrom As Integer
Public code As Integer
End Structure

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = OCM_NOTIFY Then
Dim nm As NMHDR = CType(m.GetLParam(GetType(NMHDR)), NMHDR)
If nm.code = TCN_SELCHANGING Then
Dim e As New System.ComponentModel.CancelEventArgs()
RaiseEvent SelectedIndexChanging(Me, e)
m.Result = New System.IntPtr(Convert.ToInt32(e.Cancel))
Exit Sub
End If
End If
MyBase.WndProc(m)
End Sub

Public Event SelectedIndexChanging(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs)
End Class

/claes
 
What is the value of WM_NOTIFY?
-----Original Message-----
The Win32 control provides a notification for this
but it isn't exposed through .NET. You'll need
to override TabControl to handle it. Try this:

Imports System.Runtime.InteropServices
Public Class TabControlEx
Inherits TabControl

Public Const TCN_FIRST As Integer = 0 - 550
Public Const TCN_SELCHANGING As Integer = TCN_FIRST - 2
Public Const WM_USER As Integer = &H400
Public Const OCM__BASE As Integer = WM_USER + &H1C00
Public Const OCM_NOTIFY As Integer = OCM__BASE + WM_NOTIFY

<StructLayout(LayoutKind.Sequential)> Public Structure NMHDR
Public hwndFrom As IntPtr
Public idFrom As Integer
Public code As Integer
End Structure

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = OCM_NOTIFY Then
Dim nm As NMHDR = CType(m.GetLParam(GetType (NMHDR)), NMHDR)
If nm.code = TCN_SELCHANGING Then
Dim e As New System.ComponentModel.CancelEventArgs()
RaiseEvent SelectedIndexChanging(Me, e)
m.Result = New System.IntPtr (Convert.ToInt32(e.Cancel))
Exit Sub
End If
End If
MyBase.WndProc(m)
End Sub

Public Event SelectedIndexChanging(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs)
End Class

/claes






.
 
Hi Steven,
//winuser.h
#define WM_NOTIFY 0x004E
Thanks for using microsoft online support !

Kind regards,

Ying-Shen Yu [MSFT]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "Steven J. Reed" <[email protected]>
| Sender: "Steven J. Reed" <[email protected]>
| References: <[email protected]>
<#[email protected]>
| Subject: Re: cancel change in tab selected
| Date: Thu, 21 Aug 2003 14:58:57 -0700
| Lines: 70
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNoL2valCrkqvmEQ/yXJftQee4scQ==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:50732
| NNTP-Posting-Host: TK2MSFTNGXA06 10.40.1.53
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| What is the value of WM_NOTIFY?
|
| >-----Original Message-----
| >The Win32 control provides a notification for this
| >but it isn't exposed through .NET. You'll need
| >to override TabControl to handle it. Try this:
| >
| >Imports System.Runtime.InteropServices
| >Public Class TabControlEx
| > Inherits TabControl
| >
| > Public Const TCN_FIRST As Integer = 0 - 550
| > Public Const TCN_SELCHANGING As Integer = TCN_FIRST -
| 2
| > Public Const WM_USER As Integer = &H400
| > Public Const OCM__BASE As Integer = WM_USER + &H1C00
| > Public Const OCM_NOTIFY As Integer = OCM__BASE +
| WM_NOTIFY
| >
| > <StructLayout(LayoutKind.Sequential)> Public
| Structure NMHDR
| > Public hwndFrom As IntPtr
| > Public idFrom As Integer
| > Public code As Integer
| > End Structure
| >
| > Protected Overrides Sub WndProc(ByRef m As
| System.Windows.Forms.Message)
| > If m.Msg = OCM_NOTIFY Then
| > Dim nm As NMHDR = CType(m.GetLParam(GetType
| (NMHDR)), NMHDR)
| > If nm.code = TCN_SELCHANGING Then
| > Dim e As New
| System.ComponentModel.CancelEventArgs()
| > RaiseEvent SelectedIndexChanging(Me, e)
| > m.Result = New System.IntPtr
| (Convert.ToInt32(e.Cancel))
| > Exit Sub
| > End If
| > End If
| > MyBase.WndProc(m)
| > End Sub
| >
| > Public Event SelectedIndexChanging(ByVal sender As
| Object, ByVal e As
| >System.ComponentModel.CancelEventArgs)
| >End Class
| >
| > /claes
| >
| >
| >
| >| >> Is there an event in which I can cancel a change in the
| >> tab selected. I just spent a half-hour with the
| >> documentation and couldn't figure it out.
| >>
| >> I must say that the help in vs.net is less direct and
| >> practical than the help in vs6.
| >>
| >> Do I have to go to a third party product, such as
| >> infragistics, in order to get this rather basic and
| >> crucial choice? I hope not.
| >>
| >> dennist
| >
| >
| >.
| >
|
 
Back
Top