if (!myDataset.Tables["myTable"].Columns.Contains("mySeq")) myDataset.Tables["myTable"].Columns.Add("mySeq", typeof(int));
2. Datagridview指定DataSource和 DataMember :
dataGridView1.DataSource = myDataset; dataGridView1.DataMember = "myTable";
3. Datagridview的RowPostPaint Event 新增以下 :
private voiddataGridView1_RowPostPaint(object sender,DataGridViewRowPostPaintEventArgs e) { if((dataGridView1.Rows[e.RowIndex].Cells["mySeq"].Value).ToString() == "") dataGridView1.Rows[e.RowIndex].Cells["mySeq"].Value = e.RowIndex + 1; else return; }
沒有留言:
張貼留言