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

Easy way to find a win control in next tab order

HI All:

I am currently implementing a TextBox to allow user to type the
things the user wants to search. The actual search routine is
happening on Textbox Validated event. My user wants me trap enter
key in the Search TextBox, so that after the user complete their
search string. The user can either press enter key or shift the
focus to next control. The problem I am facing I cannot easily find
out what is my next tab control on my win form. I have to write
small routine to search for. I just want to know is there anyone in
this newsgroup has better solution.
....
private void textBox1_KeyPress(object
sender,System.Windows.Forms.KeyPressEventArgs e) {
if (e.KeyChar == '\r')
{
Control ctr = FindNextTabControl
(this.textBox1.TabIndex + 1);
ctr.Focus(); // to triggle validated event to
perform the search
}
}

private Control FindNextTabControl(int TabIndex)
{
Control retCtr = null;
foreach(Control ctr in this.Controls)
{
if (ctr.TabIndex == TabIndex)
{
retCtr = ctr;
break;
}
else if (ctr.TabIndex == 0)
retCtr = ctr;
}
return retCtr;
}

private void textBox1_Validated(object sender,
System.EventArgs e)
{
//actual search here
}
....

Thanks in Advance
DK
Nov 16 '05 #1
2 5859
I don't follow what you're trying to do. If the user presses <Enter> while
in the text box then you trap that keystroke and do a search, right? From
that same text box, can't the user simply press <tab> to go to the next
control in tab order? Or am I missing something?

..ARN.

"David Kao" wrote:
HI All:

I am currently implementing a TextBox to allow user to type the
things the user wants to search. The actual search routine is
happening on Textbox Validated event. My user wants me trap enter
key in the Search TextBox, so that after the user complete their
search string. The user can either press enter key or shift the
focus to next control. The problem I am facing I cannot easily find
out what is my next tab control on my win form. I have to write
small routine to search for. I just want to know is there anyone in
this newsgroup has better solution.
....
private void textBox1_KeyPress(object
sender,System.Windows.Forms.KeyPressEventArgs e) {
if (e.KeyChar == '\r')
{
Control ctr = FindNextTabControl
(this.textBox1.TabIndex + 1);
ctr.Focus(); // to triggle validated event to
perform the search
}
}

private Control FindNextTabControl(int TabIndex)
{
Control retCtr = null;
foreach(Control ctr in this.Controls)
{
if (ctr.TabIndex == TabIndex)
{
retCtr = ctr;
break;
}
else if (ctr.TabIndex == 0)
retCtr = ctr;
}
return retCtr;
}

private void textBox1_Validated(object sender,
System.EventArgs e)
{
//actual search here
}
....

Thanks in Advance
DK

Nov 16 '05 #2
Check this article
http://blogs.duncanmackenzie.net/dun...12/13/936.aspx

-- Ricky Lee
==================================================
^o^ "When all doors are closed, God will open a Windows" ^o^
==================================================
"David Kao" <da*******@opco.com> wrote in message
news:Xn*****************************@130.81.64.196 ...
HI All:

I am currently implementing a TextBox to allow user to type the
things the user wants to search. The actual search routine is
happening on Textbox Validated event. My user wants me trap enter
key in the Search TextBox, so that after the user complete their
search string. The user can either press enter key or shift the
focus to next control. The problem I am facing I cannot easily find
out what is my next tab control on my win form. I have to write
small routine to search for. I just want to know is there anyone in
this newsgroup has better solution.
...
private void textBox1_KeyPress(object
sender,System.Windows.Forms.KeyPressEventArgs e) {
if (e.KeyChar == '\r')
{
Control ctr = FindNextTabControl
(this.textBox1.TabIndex + 1);
ctr.Focus(); // to triggle validated event to
perform the search
}
}

private Control FindNextTabControl(int TabIndex)
{
Control retCtr = null;
foreach(Control ctr in this.Controls)
{
if (ctr.TabIndex == TabIndex)
{
retCtr = ctr;
break;
}
else if (ctr.TabIndex == 0)
retCtr = ctr;
}
return retCtr;
}

private void textBox1_Validated(object sender,
System.EventArgs e)
{
//actual search here
}
...

Thanks in Advance
DK

Nov 16 '05 #3

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

Similar topics

4
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
1
by: Robert Mark Bram | last post by:
Hi All, >From an event handler attached to a control that has a tab index, is it possible to find the next control in the tab order - and then focus() on it? I am having a bit of trouble with...
5
by: Tom | last post by:
How can I find the first blank control on a form by looking at the controls in the order of their tab order? Thanks! Tom
9
by: Bob Cummings | last post by:
Greetings I have googled this to no avail, maybe someone here can help. I have a user control that has several radio buttons and text boxes. I place 5 of these user controls on a windows form....
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
5
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
9
by: TCORDON | last post by:
I have a user control that contains 2 image buttons, when you click one of them, both must change the image source, the thing is that the first time you click any one of them the page appears to do...
26
by: Martin R | last post by:
Hi, How to find first not null value in column whitout chacking whole table (if there is a not null value then show me it and stop searching, the table is quite big)? thx, Martin *** Sent...
6
by: HristiyanVasilev | last post by:
Hello there ! I'm developing a Windows appliciation that involves so called "Transparent Controls". As you would probably know, the only ( as far as i know ) way to achieve a fully transparent...
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:
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: 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?
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
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,...

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.