我在我的winforms中有一個頁面,我想要在桌面上顯示所有數據,以便用戶可以在表格中看到信息,但在winforms上。我之前沒有這樣做過,所以需要你們的一些指導,我希望它能夠一致地(當添加新記錄時)更新並且是可編輯的,以便在需要時可以刪除一行。我的桌子是「預訂」,我可以在這張桌子上添加數據的形式是「frmBooking」,所以我希望在程序運行時將預訂數據存儲在datagridview中,以便用戶可以查看他們的預訂。感謝代碼,我是:如何在winforms中更新數據網格視圖?
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);
}
}
}
你看過了綁定數據庫與數據庫? – 2013-03-27 15:41:30
我用數據庫表綁定了數據網格,但只有現有的記錄纔會顯示,而不是在程序運行時產生的新記錄.... – bandaa 2013-03-27 15:43:49
您是否添加了DGV控件來保存,添加記錄等?或者你是用你自己的代碼來做這件事嗎? – 2013-03-27 15:44:56