您的位置:首页 > 其它

dataGridView 显示数据 定位到首记录 定位到未记录的方法

2009-12-02 09:52 330 查看
显示数据

conn = new SqlConnection("server=localhost;database=TXL;uid=sa;pwd=");
SqlDataAdapter sda = new SqlDataAdapter("select 姓名,关系,地址,E_mail,邮编,手机号,QQ,电话0,电话H from TXL", conn);
DataSet ds = new DataSet();
sda.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];

在dataGridView中定位到首记录

this.dataGridView1.CurrentCell = this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex,0];

在dataGridView中定位到末记录

this.dataGridView1.CurrentCell = this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex, dataGridView1.RowCount-1];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: