110,501
社区成员
发帖
与我相关
我的任务
分享
public void ShowPc(string str)
{
SqlConnection myconn = new SqlConnection();
myconn.ConnectionString = Main.mystr;
myconn.Open();
DataSet myds = new DataSet();
SqlDataAdapter myadp = new SqlDataAdapter(str, myconn);
myadp.Fill(myds, "ksb");
dataGridView1.DataSource = myds.Tables["ksb"];
myconn.Close();
}
public void LoadCheckBox()
{
DataGridViewCheckBoxColumn checkbox = new DataGridViewCheckBoxColumn();
//列显示名称
checkbox.HeaderText = "出场";
checkbox.Name = "IsChecked";
checkbox.TrueValue = true;
checkbox.FalseValue = false;
checkbox.DataPropertyName = "IsChecked";
//列宽
checkbox.Width = 50;
//列大小不改变
checkbox.Resizable = DataGridViewTriState.False;
//添加的checkbox在dgv第一列
this.dataGridView1.Columns.Insert(0, checkbox);
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
dataGridView1.Rows[i].Cells[0].Value =true;
}
}
private void Modify_Load(object sender, EventArgs e)
{
currentpc = 1;
str = "select * from ksb where pc='" + currentpc + "' and examdate=(select val from setting where items='currentexam') order by seat";
ShowPc(str);
LoadCheckBox();
}