1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
namespace WinReferenceDataSet
{
public partial class Form2 : Form
{
private DataSet ds = null;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
ds = getds();
this.dataGridView1.DataSource = ds;
this.dataGridView1.DataMember = ds.Tables[0].TableName;
}
private void button1_Click(object sender, EventArgs e)
{
FormModeless f1 = new FormModeless();
f1.Owner = this;
f1.SetData(BindingContext, ds);
f1.Show();
}
private DataSet getds()
{
DataSet ds = new DataSet();
DataTable table1 = new DataTable("table1");
ds.Tables.Add(table1);
table1.Columns.Add(new DataColumn("PersonID", typeof(int)));
table1.Columns.Add(new DataColumn("PersonNAME", typeof(string)));
DataRow dr = table1.NewRow();
for (int i = 1; i < 11; i++)
{
dr[0] = i * 100;
dr[1] = "Nom" + i.ToString();
table1.Rows.Add(dr);
dr = table1.NewRow();
}
return ds;
}
}
} |
Partager