我有下面的代碼,它想要做什麼是更新時,我從一個單獨的表單添加新的記錄到我的表,現在我得到所有的表數據,但如果我添加新的數據,它是在這裏不可見,但保存在表格中,我必須關閉該程序並再次運行,才能使保存的數據在datagridview中可見。我的問題是我如何更新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);
}
}
}
你叫'.DataBind()'更新後? – DGibbs 2013-03-27 16:52:19
「綁定看起來像」是什麼?你可以顯示你在哪裏聲明'usersDataSet1'看起來像是在這裏丟失了一些代碼 – MethodMan 2013-03-27 16:52:27
嗯......我想我很困惑,@DJKRAZE-我只是簡單地從工具箱中添加了datagridview,然後簡單地選擇了數據源。這是我所做的 – bandaa 2013-03-27 16:57:38