dataGridView的用法

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
int a=dataGridView1.CurrentRow.Index;
string str=dataGridView1.Row[a].Cells["strName"].Value.Tostring();
DataRowState rowState=new DataRowState ();
DataTable dt=(DataTable)this.dgvStudentInfo .DataSource ;
for (int i = 0; i < dt.Rows.Count; i++)
{
//rowState == DataRowState.Added || rowState == DataRowState.Detached ||
if (rowState == DataRowState.Modified)
//int id = this.dgvStuInfo.CurrentRow.Cells[0].RowIndex;
//string stuid = this.dgvStuInfo.Rows[id].Cells[0].Value.ToString();
4、获得当前选中பைடு நூலகம்元格的值:
dataGridView1.CurrentCell.Value;
5、取选中行的数据
string[] str = new string[dataGridView.Rows.Count];
for(int i;i<dataGridView1.Rows.Count;i++)
{
if(dataGridView1.Rows[i].Selected == true)
dataGridView的几个基本操作:
1、获得某个(指定的)单元格的值:
dataGridView1.Row[i].Cells[j].Value;
2、获得选中的总行数:
dataGridView1.SelectedRows.Count;
3、获得当前选中行的索引:
dataGridView1.CurrentRow.Index;
{
//dt.Rows[i].Delete();
//dt.ImportRow(dt.Rows[i]);
//dgvStudentInfo.DataSource = dt;
//dgvStudentInfo.Refresh();
bllStudent.Update(stuModel);
}
}
选中行的某个数据
//string stuid = dgvStuInfo.Rows[0].Cells[0].Value.ToString();
{
str[i] = dataGridView1.Rows[i].Cells[1].Value.ToString();
}
}
7、获取选中行的某个数据
int a = dataGridView1.SelectedRows.Index;
dataGridView1.Rows[a].Cells["你想要的某一列的索引,想要几就写几"].Value;
相关文档
最新文档