小编Ale*_*lex的帖子

复选框数据绑定

我有System.Window.Form.CheckBox数据绑定的问题.我有代码:

checkBox1.DataBindings.Add("Checked", _movementsBindingSource, "Moved", true);
Run Code Online (Sandbox Code Playgroud)

它工作,但我想反转checkBox1.Checked.如果Moved为true,则checked = false.你能帮我解决这个问题吗?

.net c# data-binding winforms

5
推荐指数
1
解决办法
4178
查看次数

使用BackgroundWorker的ObjectContext.SaveChanges

我有ObjectContext.SaveChanges方法的问题:

  public void Save(Action<object, object> action)
    {
        EventAggregator.GetEvent<EntityServiceRequestingEvent>().Publish(true);
        var bw = new BackgroundWorker();
        var saved = false;
        bw.DoWork += (o, ee) =>
                         {
                             ProgramStatusService.Status = Resources.DatabaseSavingMessage;


                             if (!CanSave())
                             {
                                 throw new InvalidOperationException(
                                     "You must not call Save when CanSave returns false.");
                             }
                             try
                             {
                                 lock (Context)
                                 {
                                     Context.SaveChanges();
                                     saved = true;    
                                 }
                             }
                             catch (ValidationException e)
                             {
                                 MessageService.ShowError(null, string.Format(CultureInfo.CurrentCulture,
                                                                              Resources.SaveErrorInvalidEntities,
                                                                              e.Message));
                             }
                             catch (UpdateException e)
                             {
                                 var innerException = e.InnerException as SqlException;
                                 if (innerException != null && innerException.Number == 2601) …
Run Code Online (Sandbox Code Playgroud)

wpf entity-framework backgroundworker

0
推荐指数
1
解决办法
885
查看次数