public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
new Form2{bindingSource1 = this.typeGlassBindingSource}.ShowDialog();
}
}
Code (C#)
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public BindingSource bindingSource1 = new BindingSource();
public DataGridView dgv;
private void Form2_Load(object sender, EventArgs e)
{
Text = " data list:" + bindingSource1.List.Count;
dgv = new DataGridView
{
AutoGenerateColumns = false,
ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize,
DataSource = bindingSource1.DataSource,
Dock = DockStyle.Fill,
Name = "dataGridView1"
};
this.Controls.Add(this.dgv);
// bindingSource1.ResetBindings(true);
// dgv.Refresh();
}
}
จากโค้ดข้างต้น
Text = " data list:" + bindingSource1.List.Count;
ทำงานปกติครับ
แต่ DataGridView ไม่มีการแสดงค่าใดๆ
Tag : .NET, Win (Windows App), C#, VS 2012 (.NET 4.x)