I am trying to capture the event when a user goes to the Sales Transsction entry screen, clicks on Actions and then Tranasfer. I want to capture the event of clicking on transfer. I have this set of code but what happens is the message in this code pops up when the SOP screen opens or jst about any other clicks on the screen. I only want to capture the even when Transfer is clicked. How should this code be changed?
/* Register a click event for the Actions->Transfer click */ try { sopEntryForm.SopEntry.ActionButton.Change += new EventHandler(ActionButton_Change); } catch (Exception ex) { string eMsg = "004: ERROR: " + ex.Message; if (stackTraceWanted) eMsg += "\n" + ex.StackTrace; MessageBox.Show(eMsg); }
/* Method to handle Action Button change event */ private void ActionButton_Change(object sender, EventArgs e) { switch (sopEntryForm.SopEntry.ActionButton.Value) { case 0: MessageBox.Show("I clicked Transfer"); break;
case 1: MessageBox.Show("I clicked something else"); break;
default: MessageBox.Show("I think, therefore I am! " + sopEntryForm.SopEntry.ActionButton.Value.ToString()); break; } }
*This post is locked for comments
Old thread but thought I'd add this for anyone coming across it:
looks like Richared was trying to use his old Change handler when testing code hooked on ValidateBeforeOriginal - but the event args are different for the Validate handle - needs CancelEventArgs rather than EventArgs. So I suspect that s why it wasn't firing as expected.
sopEntryForm.SopEntry.ActionButton.EnterAfterOriginal += new EventHandler(ActionButton_Change); is the event that I found would work. Validate After Original did nothing. One curious thing though is when my window pops up and the user does what is needed and clicks edit they are back on the SOP Transaction Entry screen not on the transfer screen. If they click Transfer a second time they do not get my window they get the Transfer screen. This is tolerable but I am not quite sure why it is working this way.
Thanks Vaidy - couldn't have put it better myself.
EnterAfterOriginal event is triggered when the focus shifts to that particular field, in your case "Action Button". ValidateAfterOriginal event is trigger after the actual clicking action is performed.
To test this, you may simply use TAB key till you reach "Action Button". The moment "Action Button" is highlighted, EnterAfterOriginal event would get triggered. ValidateAfterOriginal would be triggered only after you click/select any of the options under the "Action Button".
Hope that helps.
This also appears to work. What is the difference between EnterAfterOriginal and ValidateAfterOriginal?
===========================================================================
/* Register a click event for the Actions->Transfer click */
try
{
sopEntryForm.SopEntry.ActionButton.EnterAfterOriginal += new EventHandler(ActionButton_Change);
}
catch (Exception ex)
{
string eMsg = "004: ERROR: " + ex.Message;
if (stackTraceWanted) eMsg += "\n" + ex.StackTrace;
MessageBox.Show(eMsg);
}
=============================================================
/* Method to handle Action Button change event */
private void ActionButton_Change(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(sopEntryForm.SopEntry.SopNumber) && sopEntryForm.SopEntry.SopType == 2 )
{
switch (sopEntryForm.SopEntry.ActionButton.Value)
{
case 0: MessageBox.Show("I clicked Transfer");
break;
case 1:
MessageBox.Show("I clicked something else");
break;
default:
MessageBox.Show("I think, therefore I am! " + sopEntryForm.SopEntry.ActionButton.Value.ToString());
break;
}
}
}
WOMM
sopEntryForm.SopEntry.ActionButton.validatebeforeoriginal += new EventHandler(ActionButton_Change); is not valid. But I will try looking for a document number and type.
Should you not be hooking into the ActionButton validatebeforeoriginal event rather than change.
Also need to check your have a document loaded and that it is the document type you expect to work with (invoice/order/quote etc).
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156