473,395 Members | 1,393 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,395 software developers and data experts.

Simple Question 6 to net

hi
in vb6 there was an option to set a button as the default action if enter is
hit, this option does not seem to be in dotnet.

I have a textbox to type in and I want the user to be able to hit the button
or hit enter/return to kick off the button action.
I have tried the following to see if I can capture the key stroke and then
act upon it, but it shows the code for normal keys but not the return key?
Private Sub txtSend_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtSend.TextChanged

MsgBox(Asc(txtSend.Text.Substring(txtSend.Text.Len gth - 1, 1)))

Nov 21 '05 #1
4 904

well this is still possible
goto the properties window of your form , look at the section "Misc" then
at the property AcceptButton select your button
now if the user presses the enter key the action below that button will be
triggered

( the CancelButton action will be triggered when the user presses the escape
button )

regards

Michel Posseth [MCP]
"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dc**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
hi
in vb6 there was an option to set a button as the default action if enter
is hit, this option does not seem to be in dotnet.

I have a textbox to type in and I want the user to be able to hit the
button or hit enter/return to kick off the button action.
I have tried the following to see if I can capture the key stroke and then
act upon it, but it shows the code for normal keys but not the return key?
Private Sub txtSend_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtSend.TextChanged

MsgBox(Asc(txtSend.Text.Substring(txtSend.Text.Len gth - 1, 1)))

Nov 21 '05 #2
Adrian wrote:
hi
in vb6 there was an option to set a button as the default action if enter is
hit, this option does not seem to be in dotnet.

I have a textbox to type in and I want the user to be able to hit the button
or hit enter/return to kick off the button action.
I have tried the following to see if I can capture the key stroke and then
act upon it, but it shows the code for normal keys but not the return key?
Private Sub txtSend_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtSend.TextChanged

MsgBox(Asc(txtSend.Text.Substring(txtSend.Text.Len gth - 1, 1)))


try to handle the txtSend.OnKeyDown event. It'll give you what you need.

Chris
Nov 21 '05 #3
Hi
thanks you both as I was trying to get the enter to default only when
hit in a text box I have followed Chris's lead thus:
If e.KeyCode.Enter Then

cmdSend.PerformClick()

End If

And it works great thanks, but I have also noted the form option for future
use!

Thanks

"Chris" <no@spam.com> wrote in message
news:Om**************@TK2MSFTNGP10.phx.gbl...
Adrian wrote:
hi
in vb6 there was an option to set a button as the default action if enter
is hit, this option does not seem to be in dotnet.

I have a textbox to type in and I want the user to be able to hit the
button or hit enter/return to kick off the button action.
I have tried the following to see if I can capture the key stroke and
then act upon it, but it shows the code for normal keys but not the
return key?
Private Sub txtSend_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtSend.TextChanged

MsgBox(Asc(txtSend.Text.Substring(txtSend.Text.Len gth - 1, 1)))


try to handle the txtSend.OnKeyDown event. It'll give you what you need.

Chris

Nov 21 '05 #4
"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:dc**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
in vb6 there was an option to set a button as the default action if
enter is hit, this option does not seem to be in dotnet.
It's no longer on the individual Controls; it's on the containing Form
(which is more logical O.O'ly) in the form (sic) of the AcceptButton
property.
I have a textbox to type in and I want the user to be able to hit the
button or hit enter/return to kick off the button action.
That'll do it.

Beware /multi-line/ testboxes, though!
I have tried ... to see if I can capture the key stroke ... but it shows
the code for normal keys but not the return key?


There are lots of "odd" little routines (PreProcessMessage,
ProcessCmdKey, etc.) that do things like this; have a rummage
around; you'll probably find one of these that does what you want.
Perhaps more importantly, though, AcceptButton /will/ do what you
want for the moment.

HTH,
Phill W.
Nov 21 '05 #5

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

Similar topics

2
by: delisonews | last post by:
I'm looking for a simple, filesystem-based message board. (No MySQL!) Something that I could include easily in my code: include '../inc/messageboard.php'; .... so that the board shows up at...
3
by: Patchwork | last post by:
Hi Everyone, Please take a look at the following (simple and fun) program: //////////////////////////////////////////////////////////////////////////// ///////////// // Monster Munch, example...
8
by: Dan | last post by:
Using XML::Simple in perl is extreemly slow to parse big XML files (can be up to 250M, taking ~1h). How can I increase my performance / reduce my memory usage? Is SAX the way forward?
6
by: Manuel Collado | last post by:
I would like to write simple, yet well structured documents with a really simple XML DTD (or schema). Either Docbook or SDocbook are overkill for this simple case. XHTML is simpler, but...
11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
4
by: Steven Blair | last post by:
I have the following number: 64521234567890 and need to apply some sort of simple encryption. Does c# have any classes for doing this. I cant use 3DES or anything as complex as. The size...
7
by: abcd | last post by:
I am trying to set up client machine and investigatging which .net components are missing to run aspx page. I have a simple aspx page which just has "hello world" printed.... When I request...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
14
by: Giancarlo Berenz | last post by:
Hi: Recently i write this code: class Simple { private: int value; public: int GiveMeARandom(void);
10
by: Phillip Taylor | last post by:
Hi guys, I'm looking to develop a simple web service in VB.NET but I'm having some trivial issues. In Visual Studio I create a web services project and change the asmx.vb file to this: Imports...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.