我有以下代码,当我从一个单独的表单向我的表中添加新记录时,它要做的是更新,此时我正在获取所有表数据,但是如果我添加新数据,它在这里不可见,但是保存在表中,我必须关闭程序并再次运行它才能使保存的数据在 datagridview 中可见。我的问题是如何更新datagridview,以便表格信息始终存在。我的代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace project
{
public partial class frmViewBookings : Form
{
public frmViewBookings()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
Form3 mainpage = new Form3();
mainpage.Show();
this.Close();
}
private void frmViewBookings_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'usersDataSet1.Booking' table. You can move, or remove it, as needed.
this.bookingTableAdapter.Fill(this.usersDataSet1.Booking);
}
}
}