b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

datagridview重叠_datagridview绑定list_datagridview右键菜单

电脑杂谈  发布时间:2017-05-30 08:07:57  来源:网络整理

datagridview绑定list_datagridview右键菜单_datagridview重叠

C#针对datagridview 操作收集的一些资料,内容比较乱,以后再整理

C#对DataGridView进行添加、修改、删除数据操作

用的是本地服务器(MySql):

设定全局变量:

MySqlConnection conn;

MySqlDataAdapter adapter;

MySqlTransaction trans;

1. // 联接

private System.Data.DataTable dbconn(string strSql)

{

string strconn = "host=localhost;database=test;user id=root;password=";

conn = new MySqlConnection();

conn.ConnectionString = strconn;

conn.Open();

this.adapter = new MySqlDataAdapter(strSql, conn);

System.Data.DataTable dtSelect = new System.Data.DataTable();

int rnt=this.adapter.Fill(dtSelect);

conn.Close();

return dtSelect;

}

2. //设定DataGridView的样式

private void setDgStyle()

{

this.dgselect.Columns.Clear();

DataGridViewCheckBoxColumn colDel = new DataGridViewCheckBoxColumn();

colDel.DataPropertyName = "Del";

colDel.Name = "Del";

colDel.Selected = false;

colDel.FalseValue = "0";

colDel.TrueValue = "1";

colDel.Width = 40;

colDel.SortMode = DataGridViewColumnSortMode.NotSortable;

colDel.HeaderText = "删除";

colDel.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;

colDel.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

this.dgselect.Columns.Insert(0, colDel);

DataGridViewTextBoxColumn colID = new DataGridViewTextBoxColumn();

colID.DataPropertyName = "ProductsSpecID";

colID.Name = "ProductsSpecID";

colID.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;

colID.HeaderText = "产品规ID";

colID.Width = 160;


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-50070-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...