Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# equivalent to Access AfterUpdate? (text, list, or combobox)

Status
Not open for further replies.

keyser456

IS-IT--Management
Nov 21, 2003
73
US
Maybe I was just spoiled in MS Access with the AfterUpdate event which fired after a person left the control (either using tab, enter, or clicking elsewhere), but it seems like there should be some equivalent in C#. I see ways to accomplish this same task, but it seems like a lot of work for something that would be so commonly used in people's programs. I could create a custom combobox and override the KeyPress field to cause validation when the person hits enter, and then use the controls Validated event as a sort of AfterUpdate, but isn't this a common enough scenario to have been included in the Combobox, ListBox, and TextBox class? For example: EnterCausesValidation or EnterTabsFromControl bool properties?
 
When TAB is pressed the focus moves to another control and leaves the current control.
When you click elsewhere the focus leaves the current control.
So use Leave event to implement after update that you want.
-obislavu-
 
Obislavu:
Thanks, but unfortunately that isn't enough since hitting the return key does not tab out. Is there some sort of EnterCausesTab property that I'm not seeing or do I have to implement a custom combobox to do that?
 
To know when the ENTER is pressed use KeyPress event and KeyPressEventArgs:

ComboBox cbx = new ComboBox ();
cbx.KeyPress += new KeyPressEventHandler(keypressed);
void Keypressed(Object o, KeyPressEventArgs e)
{

// If the ENTER key is pressed, the Handled property is set to true,
// to indicate the event is handled.
if(e.KeyChar == (char)13)
e.Handled=true;
//
//
}
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top