472,803 Members | 1,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,803 software developers and data experts.

Overriding method

Hi,

I have such problem:
On my form I have TabControl. I want to move from one tab to another
using "Next" and "Prev" button. This part works fine.

But control also supports switching between TabPagess using
combination of buttons Ctrl+Tab (forward) and Ctrl+Shift+Tab (back). I
would like to suppress such possibility.

The first think that I tried - set "TabStop" to False.

Also at the article "Control.KeyDown Event " I found such text:
"To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true.
Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are
handled by controls automatically. In order to have these keys raise
the KeyDown event, you must override the IsInputKey method in each
control on your form. The code for the override of the IsInputKey
would need to determine if one of the special keys is pressed and
return a value of true. "

The problem is that I can not find place where (how) I have to
overriding the IsInputKey method. Or is it wrong way?

Maybe somebody has an another idea how fix such problem.

Thanks
Nov 20 '05 #1
6 2591
Try this:

Public Class Test
Inherits System.Windows.Forms.TabControl

Public Sub New()
MyBase.New()
End Sub
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = keyData.Tab Or keyData = 131089 Or keyData = 65552 Then
Return True
End If
Return False
End Function
End Class

Hi,

I have such problem:
On my form I have TabControl. I want to move from one tab to another
using "Next" and "Prev" button. This part works fine.

But control also supports switching between TabPagess using
combination of buttons Ctrl+Tab (forward) and Ctrl+Shift+Tab (back). I
would like to suppress such possibility.

The first think that I tried - set "TabStop" to False.

Also at the article "Control.KeyDown Event " I found such text:
"To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true.
Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are
handled by controls automatically. In order to have these keys raise
the KeyDown event, you must override the IsInputKey method in each
control on your form. The code for the override of the IsInputKey
would need to determine if one of the special keys is pressed and
return a value of true. "

The problem is that I can not find place where (how) I have to
overriding the IsInputKey method. Or is it wrong way?

Maybe somebody has an another idea how fix such problem.

Thanks

Nov 20 '05 #2
Try this:

Public Class Test
Inherits System.Windows.Forms.TabControl

Public Sub New()
MyBase.New()
End Sub
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = keyData.Tab Or keyData = 131089 Or keyData = 65552 Then
Return True
End If
Return False
End Function
End Class

Hi,

I have such problem:
On my form I have TabControl. I want to move from one tab to another
using "Next" and "Prev" button. This part works fine.

But control also supports switching between TabPagess using
combination of buttons Ctrl+Tab (forward) and Ctrl+Shift+Tab (back). I
would like to suppress such possibility.

The first think that I tried - set "TabStop" to False.

Also at the article "Control.KeyDown Event " I found such text:
"To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true.
Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are
handled by controls automatically. In order to have these keys raise
the KeyDown event, you must override the IsInputKey method in each
control on your form. The code for the override of the IsInputKey
would need to determine if one of the special keys is pressed and
return a value of true. "

The problem is that I can not find place where (how) I have to
overriding the IsInputKey method. Or is it wrong way?

Maybe somebody has an another idea how fix such problem.

Thanks

Nov 20 '05 #3
Ok, and after Class Test would be created - how to use it in the program?
The program know only about instance of class TabControl when I put it on
the form .

Thanks,
P.S. Maybe override method is not the best desidion. Do you know another way
not to send events to the controls.
"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...
Try this:

Public Class Test
Inherits System.Windows.Forms.TabControl

Public Sub New()
MyBase.New()
End Sub
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = keyData.Tab Or keyData = 131089 Or keyData = 65552 Then
Return True
End If
Return False
End Function
End Class

Hi,

I have such problem:
On my form I have TabControl. I want to move from one tab to another
using "Next" and "Prev" button. This part works fine.

But control also supports switching between TabPagess using
combination of buttons Ctrl+Tab (forward) and Ctrl+Shift+Tab (back). I
would like to suppress such possibility.

The first think that I tried - set "TabStop" to False.

Also at the article "Control.KeyDown Event " I found such text:
"To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true.
Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are
handled by controls automatically. In order to have these keys raise
the KeyDown event, you must override the IsInputKey method in each
control on your form. The code for the override of the IsInputKey
would need to determine if one of the special keys is pressed and
return a value of true. "

The problem is that I can not find place where (how) I have to
overriding the IsInputKey method. Or is it wrong way?

Maybe somebody has an another idea how fix such problem.

Thanks

Nov 20 '05 #4
Ok, and after Class Test would be created - how to use it in the program?
The program know only about instance of class TabControl when I put it on
the form .

Thanks,
P.S. Maybe override method is not the best desidion. Do you know another way
not to send events to the controls.
"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...
Try this:

Public Class Test
Inherits System.Windows.Forms.TabControl

Public Sub New()
MyBase.New()
End Sub
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = keyData.Tab Or keyData = 131089 Or keyData = 65552 Then
Return True
End If
Return False
End Function
End Class

Hi,

I have such problem:
On my form I have TabControl. I want to move from one tab to another
using "Next" and "Prev" button. This part works fine.

But control also supports switching between TabPagess using
combination of buttons Ctrl+Tab (forward) and Ctrl+Shift+Tab (back). I
would like to suppress such possibility.

The first think that I tried - set "TabStop" to False.

Also at the article "Control.KeyDown Event " I found such text:
"To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true.
Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are
handled by controls automatically. In order to have these keys raise
the KeyDown event, you must override the IsInputKey method in each
control on your form. The code for the override of the IsInputKey
would need to determine if one of the special keys is pressed and
return a value of true. "

The problem is that I can not find place where (how) I have to
overriding the IsInputKey method. Or is it wrong way?

Maybe somebody has an another idea how fix such problem.

Thanks

Nov 20 '05 #5

This is how you would use it:
Dim WithEvents t As New Test()

t.Size = New Size(250, 250)
t.Location = New Point(0, 0)
t.TabPages.Add(New TabPage("Help"))
t.TabPages.Add(New TabPage("OK"))
Me.Controls.Add(t)

Mike wrote:
Ok, and after Class Test would be created - how to use it in the program?
The program know only about instance of class TabControl when I put it on
the form .

Thanks,
P.S. Maybe override method is not the best desidion. Do you know another way
not to send events to the controls.
"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...
Try this:

Public Class Test
Inherits System.Windows.Forms.TabControl

Public Sub New()
MyBase.New()
End Sub
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = keyData.Tab Or keyData = 131089 Or keyData = 65552 Then
Return True
End If
Return False
End Function
End Class
Hi,

I have such problem:
On my form I have TabControl. I want to move from one tab to another
using "Next" and "Prev" button. This part works fine.

But control also supports switching between TabPagess using
combination of buttons Ctrl+Tab (forward) and Ctrl+Shift+Tab (back). I
would like to suppress such possibility.

The first think that I tried - set "TabStop" to False.

Also at the article "Control.KeyDown Event " I found such text:
"To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true.
Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are
handled by controls automatically. In order to have these keys raise
the KeyDown event, you must override the IsInputKey method in each
control on your form. The code for the override of the IsInputKey
would need to determine if one of the special keys is pressed and
return a value of true. "

The problem is that I can not find place where (how) I have to
overriding the IsInputKey method. Or is it wrong way?

Maybe somebody has an another idea how fix such problem.

Thanks


Nov 20 '05 #6

This is how you would use it:
Dim WithEvents t As New Test()

t.Size = New Size(250, 250)
t.Location = New Point(0, 0)
t.TabPages.Add(New TabPage("Help"))
t.TabPages.Add(New TabPage("OK"))
Me.Controls.Add(t)

Mike wrote:
Ok, and after Class Test would be created - how to use it in the program?
The program know only about instance of class TabControl when I put it on
the form .

Thanks,
P.S. Maybe override method is not the best desidion. Do you know another way
not to send events to the controls.
"yEaH rIgHt" <no******@haha.com> wrote in message
news:10*************@corp.supernews.com...
Try this:

Public Class Test
Inherits System.Windows.Forms.TabControl

Public Sub New()
MyBase.New()
End Sub
Protected Overrides Function IsInputKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = keyData.Tab Or keyData = 131089 Or keyData = 65552 Then
Return True
End If
Return False
End Function
End Class
Hi,

I have such problem:
On my form I have TabControl. I want to move from one tab to another
using "Next" and "Prev" button. This part works fine.

But control also supports switching between TabPagess using
combination of buttons Ctrl+Tab (forward) and Ctrl+Shift+Tab (back). I
would like to suppress such possibility.

The first think that I tried - set "TabStop" to False.

Also at the article "Control.KeyDown Event " I found such text:
"To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true.
Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are
handled by controls automatically. In order to have these keys raise
the KeyDown event, you must override the IsInputKey method in each
control on your form. The code for the override of the IsInputKey
would need to determine if one of the special keys is pressed and
return a value of true. "

The problem is that I can not find place where (how) I have to
overriding the IsInputKey method. Or is it wrong way?

Maybe somebody has an another idea how fix such problem.

Thanks


Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew Durdin | last post by:
In Python, you can override the behaviour of most operators for a class, by defining __add__, __gt__, and the other special object methods. I noticed that, although there are special methods for...
3
by: Ali Eghtebas | last post by:
Hi, I have 3 questions regarding the code below: 1) Why can't I trap the KEYDOWN while I can trap KEYUP? 2) Is it correct that I use Return True within the IF-Statement? (I've already read...
9
by: James Marshall | last post by:
I'm writing a library where I want to override document.write(), but for all document objects; thus, I want to put it in the prototype. I tried Document.prototype.write= my_doc_write ; but it...
4
by: ORi | last post by:
Hi all ! There's a question I've been bothering for a while: I'm actually developing architectural frameworks for application developing and I think virtual methods, although needed because of...
17
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
3
by: Amin Sobati | last post by:
Hi, I have two classes. Class2 inhertis Class1: ----------------------------- Public Class Class1 Public Overridable Sub MySub() End Sub End Class Public Class Class2
6
by: John Cobb | last post by:
MSDN and intellisense shows the Add method of Hashtable being overridable however when I use this code: Public Class RAL Inherits Hashtable Public Overrides Sub Add(ByVal Key As String, ByVal...
6
by: bryanbabula | last post by:
I have a question about overriding i was wondering if anyone could help me with, or even suggesting a better/different way. I have no idea if this can even be done or not. I was wondering if there...
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
5
by: kj | last post by:
I'm trying to subclass file, overriding the readline method. The new method definition begins with def readline(self, size=None): line = self.file.readline(size) # etc., etc. ....where the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.