datagridview 数据处理方法 修改 删除 添加 下拉类表(15)
发布时间:2021-06-06
发布时间:2021-06-06
datagridview 数据处理方法 修改 删除 添加 下拉类表 弹出窗口
}
private void button1_Click(object sender, EventArgs e)
{
string msg = String.Format("第{0}行,第{1}列,值:
{2}",dataGridView1.CurrentCell.RowIndex,dataGridView1.CurrentCell.ColumnIndex,dataGridView1.CurrentCell.Value);
label1.Text = "选择的单元格为:" + msg;
}
private void button2_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
}
private void button3_Click(object sender, EventArgs e)
{
this.dataGridView1.AutoSizeColumnsMode =
System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; //表格自适应宽度
//DataCon datacon = new DataCon();
DataOperate dataoperate = new DataOperate();
pagesize = int.Parse(textBox1.Text); //每页显示的记录数
string strSql = "select top " + pagesize.ToString()+ " * from user_tb1 "; DataSet ds = dataoperate.getDs(strSql, "user_tb1");
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.Columns[0].ReadOnly = true; //列不可编写
//获取第1页页码
label2.Text = "1";
pagenumber = 1;
//获取总页码 SELECT Count(id) AS number1 FROM user_tb1;
strSql = "SELECT Count(id) AS number1 FROM user_tb1 ";
ds = dataoperate.getDs(strSql, "user_tb1");
int indexsum =int.Parse(ds.Tables[0].Rows[0][0].ToString());
if (indexsum % pagesize == 0)
label5.Text = (indexsum / pagesize).ToString();
else
label5.Text = (indexsum / pagesize + 1).ToString();
上一篇:《企业危机管理与风险控制》下_
下一篇:车贷项目管理系统操作手册