專案內容
C# 相關語法
using System.Data.Entity;
using WinFormsWithNavigation.Models;
namespace WinFormsWithNavigation
{
public partial class Form1 : Form
{
private NavigationContext _context;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
_context = new NavigationContext();
_context.Order.Load();
bsOrder.DataSource = _context.Order.Local.ToBindingList();
txtOrderID.DataBindings.Add("Text", bsOrder, "OrderID");
txtOrderDate.DataBindings.Add("Text", bsOrder, "OrderDate");
txtCustID.DataBindings.Add("Text", bsOrder, "CustID");
txtCustName.DataBindings.Add("Text", bsOrder, "Customer.CustName");
bindingNavigator1.BindingSource = bsOrder;
}
}
}
執行結果
沒有留言:
張貼留言