
October 12th, 2003, 05:46 PM
|
|
Contributing User
|
|
Join Date: Aug 2003
Location: Brisbane, Australia
Posts: 50
Time spent in forums: < 1 sec
Reputation Power: 10
|
|
Not so sure in VB.NET, I use C# more often. However, the concept should be same.
This is how I would do it:
I would write a KeyPressEventHandler to handle the controls (input fields) which need to have the "Enter" key as the tab key.
Code:
Control_KeyPress(object sender, KeyPressEventHandler e){
if(e.KeyChar!=Keys.Enter){
return; //skip all keys except Enter
}
//for tab index sorting
int currentIndex = ((Control)sender).TabIndex;
int nextIndex = 5000; // for tab index sorting
Control controlToFocus = null;
foreach(Control c in this.Controls){
if((c.TabIndex<nextIndex)&&c.TabIndex>currentIndex)){
if(c.TabStop){
nextIndex = c.TabIndex;
controlToFocus = c;
}
}
}
if(controlToFocus !=null){
controlToFocus.Focus();
}
}
hope it helps
|