VSTO Outlook: Avoid MailItem_PropertyChanged from being fired when updating "To" field - outlook

I am trying to update the 'To' field of an Outlook.MailItem but I want to avoid MailItem_PropertyChanged event to be fired so I unsubscribe from the event, update the 'To' field and then subscribe to the event again:
this.cryptableMailItem.PropertyChanged -= MailItem_PropertyChanged;
myOutlookMailItem.To = something;
this.cryptableMailItem.PropertyChanged += MailItem_PropertyChanged;
But it is not working, each time I update the 'To' field, MailItem_PropertyChanged is fired again and again.
What am I doing wrong?

The event fires asynchronously when the Windows message pump on the main thread runs. If you know that the next PropertyChanged event needs to be ignored, why not set a boolean flag that tells your event handler to do nothig? You can then reset the boolean flag in the event handler to make sure you prcocess it the next time it fires.

Related

Handsontable afterChange event is triggered on rows that haven't been changed

I have noticed that if I edit a row in a table containing a date the afterChanges event is triggered more than once, but it should only be triggered once because I have only added a row,
This fiddle with a simple afterChanges handler shows that each time you edit a date you get only one afterChanges event triggered.
Perhaps you are making changes to cell values inside your afterChanges event handler?
Calling setDataAtCell inside afterChanges will trigger another call to afterChanges. If you do - you need to check for source !== 'afterChange' inside you afterChanges event handler like in this fiddle.

Any way to limit how often onChange happens in a DateInput? (blueprintjs)

We're using the date input component as part of some parameterization on a page. So, as soon as the onChange event fires we want to go fetch some more data.
The problem is that the onChange fires too often as a user is typing. If I type just "Nov" that's setting a valid date of Nov-01-YYYY, and so the onChange event fires. I believe I would like to fire the onChange only when a full date has been entered, or the enter key is pressed, though I'm open to other ideas.
DateInput does not currently provide such a feature. Sounds like you're requesting an onConfirm handler. GitHub is the place to request features.

JavaFX: default button won't fire events

In my code I have bound the defaultProperty of a button to some other properties like so:
BooleanBinding isAddResourceButtonDefault
= resourceNameTextField.focusedProperty().or(
resourceTypeComboBox.focusedProperty()).or(
divisibleResourceCheckbox.focusedProperty().or(
maxInstancesTextField.focusedProperty()).or(
addResourceButton.focusedProperty()));
addResourceButton.defaultButtonProperty().bind(isAddResourceButtonDefault);
The problem is that the addResourceButton won't fire absolutely any events on pushing Enter - neither OnAction, nor OnKeyPressed.
The default property gets set just fine - I double checked (using output and ScenicView). ScenicView also doesn't show any events being fired upon hitting keys. Any ideas?
I believe TextFields (and other TextInputControls) process and consume key events that occur on them. So pressing Enter on a text field will not fire an action event on the default button (because the key event never reaches the Scene).
If you are just trying to fire the button's action event handler when enter is pressed in one of the text fields, just add the same event handler to the text fields. E.g.
EventHandler<ActionEvent> addResourceHandler = event -> {
System.out.println("Add resource");
// ...
};
addResourceButton.setOnAction(addResourceHandler);
resourceNameTextField.setOnAction(addResourceHandler);
maxInstancesTextField.setOnAction(addResourceHandler);

How to unselect any selected record in an infragistics XamDataGrid?

I have a XamDataGrid with XamComboEditor as its CellValuePresenter.
I have written a handler for XamComboEditor SelectionChanged event (XamComboSelectionChanged) that updates my collection as per selected item.
When I apply filter to the XamDataGrid from its header, it triggers XamComboSelectionChanged event handler somehow and the value from XamDataGrid.ActiveRecord gets updated due this event handler. I want to avoid this.
This problem does not occur if I don't click on any record. i.e. XamDataGrid.ActiveRecord is null.
If there is any way I can unselect the selected row my problem would be solved.
I have tried setting XamDataGrid.ActiveRecord = null in RecordFilterChanged event of XamDataGrid didn't work.
XamDataGrid.ActiveRecord.IsActive = false didn't work.
XamDataGrid.ActiveRecord.IsSelected = fals didn't work.
Also I tried to update dependency property but I can only set it to any other record only which still causes same issue:
xamDataGrid.SetValue(XamDataGrid.ActiveRecordProperty, xamDataGrid.Records[0]); -- can't set anything out of index here.
Please help
Thanks

how I can check the leave event is occured in other buttons click event in C#

I have called a leave event for a a text box and in it called another buttons event named Retrieve button. so now I just want to check in this retrieve button event weather the text box's leave event is called or not?
When you call the retrieve button event from the text box leave (blur) event you could simply add a flag into the eventArgs that you can check in the retrieve button. This flag would only be set when you implicitly call the retrieve button even from the text box leave event.
This would mean that if the retrieve event is called from other places the flag would not be set so you could tell that the call definitely came from the button leave event.

Resources