public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); this.Init(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } private void Init() { DataTable ht = new DataTable(); DataColumn objcol = new DataColumn("Keys"); objcol.DataType = typeof(System.String); ht.Columns.Add(objcol); objcol = new DataColumn("Value"); objcol.DataType = typeof(System.Int32); ht.Columns.Add(objcol); DataRow row = ht.NewRow(); row[0] = "左上"; row[1] = 1; ht.Rows.Add(row); row = ht.NewRow(); row[0] = "左下"; row[1] = 2; ht.Rows.Add(row); row = ht.NewRow(); row[0] = "右上"; row[1] = 3; ht.Rows.Add(row); row = ht.NewRow(); row[0] = "右下"; row[1] = 4; ht.Rows.Add(row); row = ht.NewRow(); row[0] = "居中"; row[1] = 5; ht.Rows.Add(row); this.local.DataSource = ht; this.local.DisplayMember = "Keys"; this.local.ValueMember = "Value"; } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) |