Hi friends ,
here is the sample code
private void txtbox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar == 13) //enter
{
txtbox2.Focus();
}
if(e.KeyChar == 27) //escape
{
txtbox.Text = "";
}
if(e.KeyChar == 37)// LEFT ARROW KEY /*here the control is not coming inside*/
{
txtboxAdjacent.Enabled = true;
txtboxAdjacent.Focus();
}
}
In the above code when executed the control is not coming inside the if(e.KeyChar == 37) loop when i pressed
left arrow key on keyboard;
how to implement the Arrow Keys in the KeyPress_event or in any other event?
hey guys plz help me out this.
-------------@@@@@@@@@@@@@--------------------------------------------------- 7 5744
Try using the KeyDown event instead:
private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if( e.KeyCode == Keys.Left)
{
textBox2.Focus();
e.Handled = true;
}
}
You will probably want to put in additional checking to make sure that's
what they really want - this will let the user move the cursor in the
textbox with the right arrow, but not the left. This would be a bit
confusing to me!
Hope this helps
- Philip
"Seash" <an*******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com... Hi friends , here is the sample code private void txtbox_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar == 13) //enter { txtbox2.Focus();
}
if(e.KeyChar == 27) //escape {
txtbox.Text = ""; }
if(e.KeyChar == 37)// LEFT ARROW KEY /*here the control is not coming
inside*/ { txtboxAdjacent.Enabled = true; txtboxAdjacent.Focus(); } }
In the above code when executed the control is not coming inside the
if(e.KeyChar == 37) loop when i pressed left arrow key on keyboard;
how to implement the Arrow Keys in the KeyPress_event or in any other
event? hey guys plz help me out this. -------------@@@@@@@@@@@@@------------------------------------------------
---
thxs philip,
But there is a problem, in the middle of text of the textbox if i press left arrow key control straight away goes to the adjacent one, this one bugging me plz help me.
----- Philip Rieck wrote: -----
Try using the KeyDown event instead:
private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if( e.KeyCode == Keys.Left)
{
textBox2.Focus();
e.Handled = true;
}
}
You will probably want to put in additional checking to make sure that's
what they really want - this will let the user move the cursor in the
textbox with the right arrow, but not the left. This would be a bit
confusing to me!
Hope this helps
- Philip
"Seash" <an*******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com... Hi friends , here is the sample code private void txtbox_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar == 13) //enter { txtbox2.Focus(); } if(e.KeyChar == 27) //escape { txtbox.Text = ""; } if(e.KeyChar == 37)// LEFT ARROW KEY /*here the control is not coming
inside*/ { txtboxAdjacent.Enabled = true; txtboxAdjacent.Focus(); } } In the above code when executed the control is not coming inside the
if(e.KeyChar == 37) loop when i pressed left arrow key on keyboard; how to implement the Arrow Keys in the KeyPress_event or in any other
event? hey guys plz help me out this. -------------@@@@@@@@@@@@@------------------------------------------------
---
------seash wrote-----------------------
Cursor should not move to the immidiate text box if there is text in the text box , it should pass each and every character before moving to the adgacent texbox
hope someone out there to crack this!
---seash
----- seash wrote: -----
thxs philip,
But there is a problem, in the middle of text of the textbox if i press left arrow key control straight away goes to the adjacent one, this one bugging me plz help me.
----- Philip Rieck wrote: -----
Try using the KeyDown event instead:
private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if( e.KeyCode == Keys.Left)
{
textBox2.Focus();
e.Handled = true;
}
}
You will probably want to put in additional checking to make sure that's
what they really want - this will let the user move the cursor in the
textbox with the right arrow, but not the left. This would be a bit
confusing to me!
Hope this helps
- Philip
"Seash" <an*******@discussions.microsoft.com> wrote in message
news:F3**********************************@microsof t.com... Hi friends , here is the sample code private void txtbox_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar == 13) //enter { txtbox2.Focus(); } if(e.KeyChar == 27) //escape { txtbox.Text = ""; } if(e.KeyChar == 37)// LEFT ARROW KEY /*here the control is not coming
inside*/ { txtboxAdjacent.Enabled = true; txtboxAdjacent.Focus(); } } In the above code when executed the control is not coming inside the
if(e.KeyChar == 37) loop when i pressed left arrow key on keyboard; how to implement the Arrow Keys in the KeyPress_event or in any other
event? hey guys plz help me out this. -------------@@@@@@@@@@@@@------------------------------------------------
---
Test the selectionstart :
private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if( e.KeyCode == Keys.Left)
{
if(textBox1.SelectionStart == 0)
{
textBox2.Focus();
e.Handled = true;
}
}
}
If your textbox is right-to-left text instead of left-to-right, then test if
the selectionstart is equal to textbox1.text.length instead of 0.
"seash" <an*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com... ------seash wrote----------------------- Cursor should not move to the immidiate text box if there is text in the
text box , it should pass each and every character before moving to the
adgacent texbox hope someone out there to crack this! ---seash
----- seash wrote: -----
thxs philip, But there is a problem, in the middle of text of the textbox if i
press left arrow key control straight away goes to the adjacent one, this
one bugging me plz help me. ----- Philip Rieck wrote: -----
Try using the KeyDown event instead:
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if( e.KeyCode == Keys.Left) { textBox2.Focus(); e.Handled = true; } }
You will probably want to put in additional checking to make
sure that's what they really want - this will let the user move the cursor
in the textbox with the right arrow, but not the left. This would be a
bit confusing to me!
Hope this helps - Philip
"Seash" <an*******@discussions.microsoft.com> wrote in message news:F3**********************************@microsof t.com... > Hi friends , > here is the sample code > private void txtbox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) > { > if(e.KeyChar == 13) //enter > { > txtbox2.Focus(); >> } >> if(e.KeyChar == 27) //escape > { >> txtbox.Text = ""; > } >> if(e.KeyChar == 37)// LEFT ARROW KEY /*here the control
is not coming inside*/ > { > txtboxAdjacent.Enabled = true; > txtboxAdjacent.Focus(); > } > } >>> In the above code when executed the control is not
coming inside the if(e.KeyChar == 37) loop when i pressed > left arrow key on keyboard; >> how to implement the Arrow Keys in the KeyPress_event or
in any other event? >> hey guys plz help me out this.
-------------@@@@@@@@@@@@@------------------------------------------------ --- >
Thxs Philip
this statement "e.Handled = true;" is necessary to include?, is there any cases of events not executing after events invocation? will the above statement gives any exception if events is not handled
-- seash
----- Philip Rieck wrote: ----
Test the selectionstart
private void textBox1_KeyDown(object sender
System.Windows.Forms.KeyEventArgs e
if( e.KeyCode == Keys.Left
if(textBox1.SelectionStart == 0
textBox2.Focus()
e.Handled = true
If your textbox is right-to-left text instead of left-to-right, then test i
the selectionstart is equal to textbox1.text.length instead of 0
"seash" <an*******@discussions.microsoft.com> wrote in messag
news:CE**********************************@microsof t.com.. ------seash wrote---------------------- Cursor should not move to the immidiate text box if there is text in th
text box , it should pass each and every character before moving to th
adgacent texbo hope someone out there to crack this ---seas ----- seash wrote: ---- thxs philip But there is a problem, in the middle of text of the textbox if
press left arrow key control straight away goes to the adjacent one, thi
one bugging me plz help me ----- Philip Rieck wrote: ---- Try using the KeyDown event instead private void textBox1_KeyDown(object sender System.Windows.Forms.KeyEventArgs e
if( e.KeyCode == Keys.Left
textBox2.Focus() e.Handled = true
You will probably want to put in additional checking to mak
sure that' what they really want - this will let the user move the curso
in th textbox with the right arrow, but not the left. This would be
bi confusing to me Hope this help - Phili "Seash" <an*******@discussions.microsoft.com> wrote in messag news:F3**********************************@microsof t.com.. Hi friends here is the sample cod private void txtbox_KeyPress(object sender System.Windows.Forms.KeyPressEventArgs e if(e.KeyChar == 13) //ente
txtbox2.Focus() if(e.KeyChar == 27) //escap
txtbox.Text = ""
if(e.KeyChar == 37)// LEFT ARROW KEY /*here the contro
is not comin inside* txtboxAdjacent.Enabled = true txtboxAdjacent.Focus()
In the above code when executed the control is no
coming inside th if(e.KeyChar == 37) loop when i presse left arrow key on keyboard how to implement the Arrow Keys in the KeyPress_event o
in any othe event hey guys plz help me out this
-------------@@@@@@@@@@@@@-----------------------------------------------
--
The statement "e.Handled = true" will simply cause the base class to stop
processing the KeyDown event. This will keep it from performing the normal
action of moving the cursor. Since in this case you don't care, it's not
entirely needed.
The event will still be handled, but the textbox assumes that you are going
to do the right thing with the message, it will simply ignore the keypress.
You don't need to worry about exceptions due to unhandled events.
"seash" <an*******@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com... Thxs Philip, this statement "e.Handled = true;" is necessary to include?, is there any
cases of events not executing after events invocation? will the above
statement gives any exception if events is not handled? -- seash
----- Philip Rieck wrote: -----
Test the selectionstart :
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if( e.KeyCode == Keys.Left) { if(textBox1.SelectionStart == 0) { textBox2.Focus(); e.Handled = true; } } }
If your textbox is right-to-left text instead of left-to-right, then
test if the selectionstart is equal to textbox1.text.length instead of 0.
"seash" <an*******@discussions.microsoft.com> wrote in message news:CE**********************************@microsof t.com... > ------seash wrote----------------------- > Cursor should not move to the immidiate text box if there is text
in the text box , it should pass each and every character before moving to
the adgacent texbox >> hope someone out there to crack this! > ---seash >> ----- seash wrote: ----- >> thxs philip, > But there is a problem, in the middle of text of the textbox
if i press left arrow key control straight away goes to the adjacent one,
this one bugging me plz help me. >> ----- Philip Rieck wrote: ----- >>> Try using the KeyDown event instead: >> private void textBox1_KeyDown(object sender, > System.Windows.Forms.KeyEventArgs e) > { > if( e.KeyCode == Keys.Left) > { > textBox2.Focus(); > e.Handled = true; > } > } >>> You will probably want to put in additional checking to
make sure that's > what they really want - this will let the user move the
cursor in the > textbox with the right arrow, but not the left. This
would be a bit > confusing to me! >> Hope this helps > - Philip >>> "Seash" <an*******@discussions.microsoft.com> wrote in
message >
news:F3**********************************@microsof t.com... >> Hi friends , >> here is the sample code >> private void txtbox_KeyPress(object sender, > System.Windows.Forms.KeyPressEventArgs e) >> { >> if(e.KeyChar == 13) //enter >> { >> txtbox2.Focus(); >>> } >>> if(e.KeyChar == 27) //escape >> { >>> txtbox.Text = ""; >> } >>> if(e.KeyChar == 37)// LEFT ARROW KEY /*here the control is not coming > inside*/ >> { >> txtboxAdjacent.Enabled = true; >> txtboxAdjacent.Focus(); >> } >> } >>>> In the above code when executed the control is not coming inside the > if(e.KeyChar == 37) loop when i pressed >> left arrow key on keyboard; >>> how to implement the Arrow Keys in the KeyPress_event or in any other > event? >>> hey guys plz help me out this.
-------------@@@@@@@@@@@@@-----------------------------------------------
- > --- >>
The statement "e.Handled = true" will simply cause the base class to stop
processing the KeyDown event. This will keep it from performing the normal
action of moving the cursor. Since in this case you don't care, it's not
entirely needed.
The event will still be handled, but the textbox assumes that you are going
to do the right thing with the message, it will simply ignore the keypress.
You don't need to worry about exceptions due to unhandled events.
"seash" <an*******@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com... Thxs Philip, this statement "e.Handled = true;" is necessary to include?, is there any
cases of events not executing after events invocation? will the above
statement gives any exception if events is not handled? -- seash
----- Philip Rieck wrote: -----
Test the selectionstart :
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if( e.KeyCode == Keys.Left) { if(textBox1.SelectionStart == 0) { textBox2.Focus(); e.Handled = true; } } }
If your textbox is right-to-left text instead of left-to-right, then
test if the selectionstart is equal to textbox1.text.length instead of 0.
"seash" <an*******@discussions.microsoft.com> wrote in message news:CE**********************************@microsof t.com... > ------seash wrote----------------------- > Cursor should not move to the immidiate text box if there is text
in the text box , it should pass each and every character before moving to
the adgacent texbox >> hope someone out there to crack this! > ---seash >> ----- seash wrote: ----- >> thxs philip, > But there is a problem, in the middle of text of the textbox
if i press left arrow key control straight away goes to the adjacent one,
this one bugging me plz help me. >> ----- Philip Rieck wrote: ----- >>> Try using the KeyDown event instead: >> private void textBox1_KeyDown(object sender, > System.Windows.Forms.KeyEventArgs e) > { > if( e.KeyCode == Keys.Left) > { > textBox2.Focus(); > e.Handled = true; > } > } >>> You will probably want to put in additional checking to
make sure that's > what they really want - this will let the user move the
cursor in the > textbox with the right arrow, but not the left. This
would be a bit > confusing to me! >> Hope this helps > - Philip >>> "Seash" <an*******@discussions.microsoft.com> wrote in
message >
news:F3**********************************@microsof t.com... >> Hi friends , >> here is the sample code >> private void txtbox_KeyPress(object sender, > System.Windows.Forms.KeyPressEventArgs e) >> { >> if(e.KeyChar == 13) //enter >> { >> txtbox2.Focus(); >>> } >>> if(e.KeyChar == 27) //escape >> { >>> txtbox.Text = ""; >> } >>> if(e.KeyChar == 37)// LEFT ARROW KEY /*here the control is not coming > inside*/ >> { >> txtboxAdjacent.Enabled = true; >> txtboxAdjacent.Focus(); >> } >> } >>>> In the above code when executed the control is not coming inside the > if(e.KeyChar == 37) loop when i pressed >> left arrow key on keyboard; >>> how to implement the Arrow Keys in the KeyPress_event or in any other > event? >>> hey guys plz help me out this.
-------------@@@@@@@@@@@@@-----------------------------------------------
- > --- >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Arno |
last post by:
Hello,
I am trying to edit a textbox which contains a number. When focus is
on the textbox, and a user press the "arrow up", I would like the
textbox value to increase of 100, and at the opposite...
|
by: Marcos Ribeiro |
last post by:
Does anyone knows how to change the cursor when the mouse is over a selected
text on a textbox or richtextbox? (similar effect on Window Wordpad)
From IBeam to Arrow for drag & drop purpouses...
|
by: DotNetShadow |
last post by:
Hi Guys,
I have been having this problem recently where I have a form with a
textbox and button, if in the button event I have the following:
Private Sub Button1_Click(ByVal sender As...
|
by: Rader |
last post by:
As the textbox is focused,if I press the keys up/down arrow instead of
other keys like a,b,c......
the input cursor moves left and right.Now its the problem,I want the
cursor stay where it...
|
by: David Veeneman |
last post by:
I'm creating a UserControl that uses a LinkLabel. For reasons that I won't
bore everyone with, I don't want the LinkLable to show the default hand
cursor when the mouse enters the control. Should...
|
by: VanKha |
last post by:
How to move the cursor( I'm programming with Win32 console applications in visual c++ 6.0) by letting the user type in arrow keys(and obviously, I will then have some variable column and row and use...
|
by: sandromani |
last post by:
Hello,
I was wondering if there was a way (in c++) to move the cursor when pressing the arrow keys instead of getting ^[[C resp. ^[[D (left resp. right arrow) in the cin input - I am using linux. I...
|
by: ivan |
last post by:
Hello,
How do I move the keyboard cursor position in a Tix.HList?
I am using an HList with the right mouse button bound to pop up a
menu. If the right click is done on an unselected item, I...
|
by: michels287 |
last post by:
Right now I have a touchscreen with a virual keyboard.
I would like to create arrow keys. If the user messed up the inputted text, he can move the blinking cursor left one space at a time between...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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...
|
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,...
|
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...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |