473,385 Members | 2,015 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,385 software developers and data experts.

Up Down Arrows as TAB Key

Bob
Hello:

I'm tring to make the down arrow act as a tab key and the up arrow act as
like (-TAB.).

I have this for the down arrow but nothing happens.

Protected Overrides Function ProcessDialogKey(ByVal keyData As Keys) As
Boolean
MyBase.ProcessDialogKey(keyData)
If keyData = System.Windows.Forms.Keys.Down Then
keyData = System.Windows.Forms.Keys.Tab
End If
End Function
TIA

Bob
Nov 21 '05 #1
10 7152
Put the call to the MyBase.ProcessDialogKey(keyData) AFTER the if
statement.

Protected Overrides Function ProcessDialogKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Down Then
keyData = Keys.Tab
End If
MyBase.ProcessDialogKey(keyData)
End Function
"Bob" <no****@nospammers.com> wrote in message
news:C2hRe.26816$FL1.13685@trnddc09...
Hello:

I'm tring to make the down arrow act as a tab key and the up arrow act as
like (-TAB.).

I have this for the down arrow but nothing happens.

Protected Overrides Function ProcessDialogKey(ByVal keyData As Keys) As
Boolean
MyBase.ProcessDialogKey(keyData)
If keyData = System.Windows.Forms.Keys.Down Then
keyData = System.Windows.Forms.Keys.Tab
End If
End Function
TIA

Bob

Nov 21 '05 #2
Bob
Some Guy:

Strange how my original post didn't show up where I intended. Thanks for the
response despite my screw up.

Your sugextion looks like it should work based on other articles. I'm
thinking I'm missing one little bit of this. Maybe I'm putting it in the
wrong place in my code.

I tried calling it from a controle like this

Dim MyKey As System.Windows.Forms.Keys
MyBase.ProcessDialogKey(MyKey)

Yet nothing happens. I would like it to work through out the whole form. Do
I need to raise the event somewhere? Also, will it slow things down or would
I be better to try to convince the client to use traditional methods to
navigate the controles. Please keep in mind I have 327 controles.

Thanks Again

TIA

Bob
Nov 21 '05 #3
This code sets MyKey to none. So nothing happens.

Dim MyKey As System.Windows.Forms.Keys
MyBase.ProcessDialogKey(MyKey)

Try: Dim MyKey As System.Windows.Forms.Keys=Keys.Tab

"Bob" <no****@nospammers.com> wrote in message
news:ZeCRe.7650$__1.4593@trnddc07...
Some Guy:

Strange how my original post didn't show up where I intended. Thanks for
the response despite my screw up.

Your sugextion looks like it should work based on other articles. I'm
thinking I'm missing one little bit of this. Maybe I'm putting it in the
wrong place in my code.

I tried calling it from a controle like this

Dim MyKey As System.Windows.Forms.Keys
MyBase.ProcessDialogKey(MyKey)

Yet nothing happens. I would like it to work through out the whole form.
Do I need to raise the event somewhere? Also, will it slow things down or
would I be better to try to convince the client to use traditional methods
to navigate the controles. Please keep in mind I have 327 controles.

Thanks Again

TIA

Bob

Nov 21 '05 #4
keyData is passed in by value, so how can you change it? I don't
believe you can change the value of an argument unless it has been
passed in by reference, so I don't believe your function will actually
change the value of keyData. In fact, I'm surprised you don't get an
exception there.

I think you have to use the focus method to change focus, something
like
If keyData = System.Windows.Forms.Keys.Down Then
cmdNextButton.Focus()
End If
And I think you'd have to keep track of the order you want the tabs to
go in, or else search all the control properties yourself to find out
which one should get focus next and then manually set focus to that
particular control. In VB6 I've used a function (API function I think)
called SendKeys. Perhaps you can use that to send a tab to your
application whenever it sees a down arrow. I've not used it yet in
vb.net. Perhaps something like (not sure of the SendKey args):
If keyData = System.Windows.Forms.Keys.Down Then
SendKeys(application.hInstance,
System.Windows.Forms.Keys.Tab)
End If

Good luck.
Mark H.

Nov 21 '05 #5
Bob
Some Guy & Mark:

Thanks to both of you for the responses. Some Guy's response actually made
it so all the keys acted as a TAB key. However, this gave me some leads to
work with and helped me figure it out.

Mark.

I certainly see what you mean and when you look below at the code that is
working, you'll fall of your chair. I still have not fully tested it but so
far it works ok with one small yet probably resolvable issue. I've yet to
have any errors at all.

Protected Overrides Function ProcessDialogKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
'MyBase.ProcessDialogKey(keyData) <<--Note that this line is
comented out.
End Function

'If I remove the above function entirely, the down arrow does nothing. Even
when I press it in other Private Subs for 'KeyDown events in other controles
and the TAB key doesn't work at all. Strange don't you think?

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Dim MyKey As System.Windows.Forms.Keys
If e.KeyCode = Keys.Down Then
MyKey = Keys.Tab
ElseIf e.KeyCode = Keys.Tab Then
MyKey = Keys.Tab
End If
MyBase.ProcessDialogKey(MyKey)
End Sub

The one small issue to resolve as of now is the following

I have an inherited user controle I made. It's a TextBox that I set to
MultiLine = True and ScrollBars = Verticle in my application(Not when I
built the controle). It's designed to move to the upper left portion of the
form and resize to (636, 326) when the F1 key is pressed and return to it's
original size and position when ESC is pressed. This also continues to
function as it should.

The down arrow acts as a TAB key intill it encounters my controle. When the
cursor reaches my controle, the down arrow key does nothing untill I press
the TAB key or click the next controle. Then the down arrow again functions
as the TAB key. However, the TAB key continues to function normally through
out all the controles on the form.

YEAH, I'm scratching my head too.

Bob
Nov 21 '05 #6
Bob
Mark:
I think you have to use the focus method to change focus, something like If keyData = System.Windows.Forms.Keys.Down Then
cmdNextButton.Focus()
End If
I forgot to mention,

That would take a lot of code as I have more than 327 controles on my form
that TabStop = True. I must intercept the Down Arrow key press in the forms
KeyDown event.
If keyData = System.Windows.Forms.Keys.Down Then
SendKeys(application.hInstance, System.Windows.Forms.Keys.Tab)
End If


Now thats interesting. I may able to refine my code with what you gave me.
I'll be sure and post my results.

Thank you

Bob
Nov 21 '05 #7
What's the problem?

Protected Overrides Function ProcessDialogKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Up Then
keyData = Keys.Tab
MyBase.ProcessDialogKey(keyData)
End If
End Function

"Bob" <no****@nospammers.com> wrote in message
news:41_Re.229$AB4.42@trnddc03...
Mark:
I think you have to use the focus method to change focus, something like

If keyData = System.Windows.Forms.Keys.Down Then
cmdNextButton.Focus()
End If


I forgot to mention,

That would take a lot of code as I have more than 327 controles on my form
that TabStop = True. I must intercept the Down Arrow key press in the
forms KeyDown event.
If keyData = System.Windows.Forms.Keys.Down Then
SendKeys(application.hInstance, System.Windows.Forms.Keys.Tab)
End If


Now thats interesting. I may able to refine my code with what you gave me.
I'll be sure and post my results.

Thank you

Bob

Nov 21 '05 #8
Bob
Some Guy:

There is no problem. You've been a great help. Someone else responded also
and maybe he didn't see your post so maybe he thought is wasn't resolved. He
didn't seem to think it would work at all but actually it works great. It
was just hanging on one of my inherited user controles but I fixed that too
with a little modification to my controle.

Thanks for helping

Bob
Nov 21 '05 #9
Bob
Some guy:

I'm sorry. My response was to Marks response. HEHEHE. Everything is fine.

Thanks again

Bob
Nov 21 '05 #10
Bob:
Your new code should work now because you are no longer changing the
key that was passed in by value. You're making a new vairable MyKey
and then (recursively sort of) calling the function again but with
MyKey instead of the original key. I think this should work.

Not exactly sure about your other problem but maybe since it's a text
field it's different. Maybe the text field has focus and is expecting
you to type something into it, and it thinks the arrow key is just like
any other key you might want to type, like regular letters, etc. You
might have to make this a special case and put some code into the event
(if it has one) for that control that gets fired off when the value
changes.
Mark H.

Nov 21 '05 #11

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

Similar topics

4
by: Jerald | last post by:
Hi. I've just installed 2.3.4 from the source on a linux box. In the interactive mode, up/down arrows do not work. When I press 'up' python prints '^[[A' and down gives '^[[B' What is wrong? ...
10
by: Ryan McGeary | last post by:
In a <select> drop-down, the onchange event isn't called when scrolling through the dropdown using the mouse-wheel and when crossing over a new <optgroup>. Using the example below, notice how...
4
by: DaveO | last post by:
Hi All I have no experience in JavaScript ( only html and ASP ). I would like to add a Menu ( with multi level drop down sub menu's ) to my web site. I have tried using a DHTML Menu...
0
by: Eddie Smit | last post by:
Hi all, In our database we have a form with a subform. If this subform contains some records, but they al 'fit' in this subform one can scroll down with the mouse. But one CAN NOT SCROLL UP...
1
by: Richard Coutts | last post by:
I have a Continous Form with 5 or so fields for each record, in a line from left to right. Because the Contuous Form lists several records at once, the form looks pretty much like a Datasheet. ...
0
by: Jim H | last post by:
I'm trying to use an owner draw ListBox by subscribing to the DrawItem event to draw my custom control as an item in the ListBox. This event is triggered when I drag the scroll button but NOT when...
2
by: kalp suth via DotNetMonster.com | last post by:
I want to create arrows using lines on a picture in the picture box. On clicking the button "btnShowAll", the image is loaded and the lines drawn. "RGSShowAll()" calls "DrawObjs()" which does the...
2
by: Notgiven | last post by:
Assuming I find some code that allows you to drag graphics around the page, ideally, I want the relationship between two graphics to be displayed as linked arrows. For example (imagine this in...
1
by: karaballo | last post by:
Hi All, How to trap arrow key down event on MDIChild form? Form alone works fine without MDI container. I think, ToolStrip stole these arrows key down events. How I can redirect arrow key down...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.