![](/img/trans.png)
[英]Background worker will not run “RunWorkerCompleted” after e.cancel = true;
[英]Esc in GridViewDateTimeColumn inside radDataGridView after I did an e.Cancel = true in Row Validation
我遇到了問題,一直在網上搜索,找不到任何可以幫助我的東西。
這是我的問題。 我正在WinForm中工作,c#
我有一個網格,其中GridViewDateTimeColumn類型的Column。 當用戶更新行時,我會在RowValidating事件中對其進行檢查,如果遇到重復的日期或其他錯誤,則會向用戶顯示一條消息,並執行e.cancel = true來不驗證行。 但是如果我按ESC。 我無法像以前一樣取消所有更改。知道怎么做嗎?
這是我的代碼:
private void grdPirteyMenahel_RowValidating(object sender, RowValidatingEventArgs e)
{
try
{
Cursor.Current = Cursors.WaitCursor;
if (e.Row != null)
{
//Generate a service to connect to DB
var factory = new MezumanimChannelFactory<IKerenService>(ServiceConsts.SERVICE_KEREN);
var service = factory.CreateChannel();
string sError = string.Empty;
//here I call a SP in the database that check if the dates are correct (column of dates are call it "MiTaarich" and "AdTaarich".
//The SP return a String with the error, if there is no error it will return and empty string
sError = GetErrorPirteySacharMenahel(Convert.ToDateTime(e.Row.Cells["MiTaarich"].Value), Convert.ToDateTime(e.Row.Cells["AdTaarich"].Value), Convert.ToInt32(e.Row.Cells["Kod"].Value));
if (sError != string.Empty)
{
e.Cancel = true;
RadMessageBoxHelper.Alert(sError);
}
}
}
catch (Exception ex)
{
Elad.Mezumanim.Client.Utils.Log.LogUtil.write(ex);
e.Cancel = true;
RadMessageBoxHelper.Alert(Messages.DataDisplayError, this);
}
finally
{
Cursor.Current = Cursors.Default;
}
}
當我收到錯誤消息時,我也嘗試添加此代碼:
DataTable dt = (grdPirteyMenahel.DataSource as DataTable);
dt.RejectChanges();
但這可以恢復以前的日期值(有什么用),但是當我按ESC時不會讓我離開該行
知道如何解決嗎?
非常感謝您,艾爾
好的,我問Telerik了,然后,Y給了我一個解決方案。 它不是一個真正的解決方案,它更像是一個修補程序,但是目前對我有好處。
謝謝艾爾
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.