Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
355
UltraCombo Issue while try to cancel value change Event
posted

          I want to cancel the value changed Event based on certain condition.

  • based on certain condition i popup one message box with Yes or No Option.
  • If user selects No. I need to cancel the event.
  • I have stored previous value in some variable.
  • I reset the previous value into combo.
  • Messagebox comes twice. That means, the event fires two times.

         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:

  • AutoCompleteMode - Append
  • DropDownStyle - DropDown

Event Fired:

  • ItemNotInList - (For Inserting new value into the database)
  • ValueChanged - (For canceling event based on certain condition)

Sample Code 

private void ifgCboTest_ValueChanged(object sender, EventArgs e)

{ 

 

try

{

Cursor = 

 

Cursors.WaitCursor; 

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;

_isFromValueChanged = 

false;  

 

return;  

}

}

//TODO }catch (Exception exifgCboTest_ValueChanged)

 

}

 

{

}

finally

{

 

if (!_isFromValueChanged)

{ 

if (ifgCboTest.SelectedRow != null) Convert.ToInt32(ifgCboTest.Value);  

{

_oldID = 

 

}

else

_oldID = 0;

}

Cursor = 

 

} 

Cursors .Default;

Parents Reply Children