Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Last Control having focus
Message
From
17/01/2007 20:01:01
 
 
To
16/01/2007 15:09:31
Jeff Corder
Ambit Technologies, LLC
Missouri, United States
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
01186047
Message ID:
01186492
Views:
19
Jeff,

This may be a bit kludgy too, but it might be acceptable to you because you'll only need to monitor the button event. Try using the MouseEnter event, and then save the ActiveControl at that point:
private void MyDetailButton_MouseEnter(object sender, EventArgs e)
{
	this.LastActiveControl = this.ActiveControl;
}
Then the click can process the LastActiveControl:
private void MyDetailButton_Click(object sender, EventArgs e)
{
	// Do something with this.LastActiveControl
}
~~Bonnie



>I'm working on a form with a 'detail' button. When the user presses it, I want to provide detail based on the control that had focus when the user pressed the button (i.e. before the button gets focus). Obviously the Enter() method doesn't work, focus is already at the button. So far I have two ideas and I'm not crazy about either one:
>
>- In the Validated() event, store the control name to a module level variable and use that in the button Click() event. I REALLY don't like this one - I need code in every control I'm interested in.
>
>- Add a timer and store the name of the active control to a module level variable and don't update it if the current control is a button. I just think there must be a better way than this.
>
>Any ideas on a better solution?
>
>Thanks,
>Jeff
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform