C#绑定的表适配器在调用两次后才会更新

C#绑定的表适配器在调用两次后才会更新,c#,.net-4.0,tableadapter,C#,.net 4.0,Tableadapter,我是vb.net中的C#新手,现在正在制作一些模拟绑定应用程序。我对以下代码有问题。如果我拍摄了一张图片并退出应用程序,则没有变化。即使我移动一排。然而,如果我上传一个图像,移动到另一行,然后添加另一个图像。退出应用程序后,第一个映像将出现,但第二个映像不会出现 简言之,我必须尝试上传到另一个记录之前,我真正想要更新的记录将这样做 using System; using System.Collections.Generic; using System.ComponentModel; using

我是vb.net中的C#新手,现在正在制作一些模拟绑定应用程序。我对以下代码有问题。如果我拍摄了一张图片并退出应用程序,则没有变化。即使我移动一排。然而,如果我上传一个图像,移动到另一行,然后添加另一个图像。退出应用程序后,第一个映像将出现,但第二个映像不会出现

简言之,我必须尝试上传到另一个记录之前,我真正想要更新的记录将这样做

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace DBUserManagement
{    
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dsUsers.Users' table. You can move, or remove it, as needed.
            this.usersTableAdapter.Fill(this.dsUsers.Users);
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (DialogResult.OK == ofd.ShowDialog())
            {
                imgUser.SizeMode = PictureBoxSizeMode.StretchImage;
                imgUser.Image = new Bitmap(ofd.OpenFile());
                //update bound field.
                usersTableAdapter.Update(dsUsers);
            }
        }
    }
}
关于我遗漏了什么或没有正确理解什么,有什么想法吗?谢谢你的帮助


/p

答案是我需要调用BindingSource的.EndEdit();方法

所以我猜这是因为绑定源仍然掌握着一些东西

不管怎样,我似乎走对了方向,我在MSDN上查阅了详细信息:)