I want to cancel the value changed Event based on certain condition.
If i choose value from the dropdown, then it is ok. But if i type value in the dropdown, then that message comes twice.
What can i do for this? Is any otherway to handle this scenario?
UltraCombo Property:
Event Fired:
Sample Code
private void ifgCboTest_ValueChanged(object sender, EventArgs e)
{
try
Cursor =
if (_isFromValueChanged)
return;
if (ifgCboTest.SelectedRow != null )
UltraGridRow ugRow = ifgCboTest.SelectedRow;
if (ugRow.Cells["Desc"] != null && ugRow.Cells["Desc"].Value != DBNull.Value && !string.IsNullOrEmpty(ugRow.Cells["Desc"].Text.Trim())) if (!string.IsNullOrEmpty(ifgtxtNotes.Text.Trim()))
DialogResult dlg_Result = MessageBox.ShowMessageBoxYesNo(Resources.Messages.TestDetail, "Continue.It will overwrite existing description", global::Utils.MessageBoxExLib.MessageBoxExIcon.Question);
if (dlg_Result == DialogResult.No) true;
_isFromValueChanged =
//ifgCboTest.SelectedRow = null;
if (_oldID > 0)
Utils.SetValueForCombo(_oldID, ifgCboTest);
else
ifgCboTest.SelectedRow = null;
}
//TODO }catch (Exception exifgCboTest_ValueChanged)
finally
if (!_isFromValueChanged)
if (ifgCboTest.SelectedRow != null) Convert.ToInt32(ifgCboTest.Value);
_oldID =
_oldID = 0;
I am having trouble validating the change for UltraCombo droplist. My ValueChange event happens and the validaing event does not get called. Am i doing something wrong. I basically want to add a message before the change and if the uses says cancel... no change to the dropdown. Can you help!
Thanks Von
I also ensured that the cmbManPaymentItemType.CasuesValidation is set to true. Also i am binding to a datatable.
CausesValidation only comes into play on the control that focus is move to, not the control from which focus is being lost. So setting this property on the combo has no effect on the combo itself. It determines what happens when you are on some other control and you edit that control and then click on (or tab to) the combo.
Are you expecting the Validating event to fire immediately after ValueChanged? Because the event does not work that way. Validating fires when the user tries to leave the control, not every time they change something.
If that is not the problem, then what control are you going to when you lose focus on the combo? There are some controls that do not take focus and therefore do not trigger validation, such as Toolbars.
Hi Mike,
I am expecting some event say 'ValueChanging' to fire just before ValueChanged.
e.g. if user is changing value from A1 to A2, I want to pop up a message before value is changed asking ' do you want to save changes for A1?...'
If useer says yes, the combo should show 'A1' if no, value should be changed to 'A2'
As you have explained, the validating event gets fired when focus is lost from combo.
Awaiting for your response.
There's no event that fires before the value is changed. The best you could do here is trap ValueChanged and prompt the user and then if they chose to Cancel, you could set the Value back to what it was originally.
Hi,
I agree with you that this would be a great feature. I think the reason there isn't one is because of DataBinding. If your combo's Value is bound to a data source adn the data source changes, then cancelling the update is not an option. So that makes it tough to implement such a thing.
But there are ways it can be done. I recommend that you Submit a Feature Request.
There should be a value_chaning event or the value changed event should have old an new values in the eventargs.