473,378 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Overriding ProcessTabKey stops tab working in VB.NET

Hi,

I have several controls on one VB.NET form, which uses the tabindex to set
the focus in the correct order when tab is pressed. However, if "Yes" is
selected in combo1, and tab is pressed then I want to tab straight to
combo3. Otherwise, the tabbing should behave as normal.

Tab isn't detected on KeyPress or KeyDown events, so I tried this...
Protected Overrides Function ProcessTabKey(ByVal forward As Boolean) As
Boolean

If combo1.Focused and combo1.Text = "Yes" Then
Combo3.Focus()
Else
'Return False ??
'MyClass.ProcessTabKey(forward) ??
'Me.ProcessTabkey(forward) ??
End If

End Function
....Which works fine when the focus is on combo1 and the text is "Yes", but
when focus is with any other control, pressing tab doesn't work, i.e. the
focus stays where it is.

I think I need to call the parent class which I've overridden to pass any
other condition to be handled normally, but don't know how.

In the above example, "Return False" does nothing, and the other two cause a
StackOverflow, as it's just calling itself rather than back to the base
class.

I remember in Java you could call "this" to pass back to the parent class.

Setting KeyPreview on the form at design time seems to have no effect either

Any ideas how you do it in VB.NET?

Thanks, Steve
Nov 21 '05 #1
2 2609
"Steve Harrison" <ma**@steve.harrison.name> schrieb
Hi,

I have several controls on one VB.NET form, which uses the tabindex
to set the focus in the correct order when tab is pressed. However,
if "Yes" is selected in combo1, and tab is pressed then I want to
tab straight to combo3. Otherwise, the tabbing should behave as
normal.

Tab isn't detected on KeyPress or KeyDown events, so I tried this...
Protected Overrides Function ProcessTabKey(ByVal forward As
Boolean) As Boolean

If combo1.Focused and combo1.Text = "Yes" Then
Combo3.Focus()
Else
'Return False ??
'MyClass.ProcessTabKey(forward) ??
'Me.ProcessTabkey(forward) ??
End If

End Function
...Which works fine when the focus is on combo1 and the text is
"Yes", but when focus is with any other control, pressing tab
doesn't work, i.e. the focus stays where it is.

I think I need to call the parent class which I've overridden to
pass any other condition to be handled normally, but don't know how.

In the above example, "Return False" does nothing, and the other two
cause a
StackOverflow, as it's just calling itself rather than back to the
base class.

I remember in Java you could call "this" to pass back to the parent
class.

Setting KeyPreview on the form at design time seems to have no
effect either

Any ideas how you do it in VB.NET?

....
else
return mybase.processtabkey(forward)
end if

See also:
http://msdn.microsoft.com/library/en...ingMethods.asp
(same via <F1>)
Armin

Nov 21 '05 #2
I think I need to call the parent class which I've overridden to pass any
other condition to be handled normally, but don't know how.


You want MyBase.ProcessTabKey(forward), I think

MyBase is the VB.NET keyword that is used to call back to a parent
class - you will often see it crop up in overriden procedures.

--
Larry Lard
Replies to group please

Nov 21 '05 #3

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

Similar topics

0
by: sam | last post by:
I am running win2k3, iis6, access db's, for a web app. The problem is that asp stops working randomly. No errors in IIS log, no errors in even viewer. It just stops serving asp. Restarting IIS...
1
by: Steve | last post by:
I have almost got this no touch deployment of WinForms working Except... 1) Occasionally the launching of the application stops and I get the IE Message "The page cannot be found". If I restart...
2
by: Steve Harrison | last post by:
Hi, I have several controls on one VB.NET form, which uses the tabindex to set the focus in the correct order when tab is pressed. However, if "Yes" is selected in combo1, and tab is pressed...
3
by: news.microsoft.com | last post by:
Hi, It is possible to override a non virtual method with the "new" keyword So how is this different from specifying a method as virtual then providing the override keyword? Is there any...
2
by: Martin Hjärtmyr | last post by:
I have a program that uses Hotkeys! And they works just fine! I use this hotkeylib:...
2
by: ESPNSTI | last post by:
Hi, I'm very new to C# and .Net, I've been working with it for about a month. My experience has been mainly with Delphi 5 (not .Net). What I'm looking for is for a shortcut way to override a...
2
by: Nikhil Patel | last post by:
Hi all, I installed an asp.net application on a client's machine on Friday. It uses a Sql Server database as backend. Database server and Web server are on different machines but same domain. The...
3
by: Terry Olsen | last post by:
I have a windows service that has been running fine for almost 6 months. Last week, it just stopped working. It is still in the task list and still shows "started" in the service manager. There...
6
by: Ben | last post by:
I'm having a really hard time trying to figure out how to override the drawing in my class derived from Button. When I set the text property, the drawing seems to be taking place in the set...
3
by: Bill Fuller | last post by:
I have an application that is modifying the ENTER key to use this.ProcessTabKey() for data entry screens (replacing a green-screen Telenet app). I would like to do the equivilent of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.