日期:2014-05-18 浏览次数:20882 次
DataGridViewComboBoxColumn co_sex = new DataGridViewComboBoxColumn(); co_sex.DataPropertyName = "sSex"; co_sex.HeaderText = "性别"; DataTable dt = new DataTable(); dt.Columns.Add("sexname"); dt.Columns.Add("sexvalue"); DataRow dr = dt.NewRow(); dr[0] = "男"; dr[1] = "1"; dt.Rows.Add(dr); DataRow dr1 = dt.NewRow(); dr1[0] = "女"; dr1[1] = "2"; dt.Rows.Add(dr1); co_sex.DataSource = dt; co_sex.ValueMember = "sexvalue"; co_sex.DisplayMember = "sexname"; this.datagridview1.Columns.Add(co_sex);
------解决方案--------------------
http://forums.microsoft.com/china/ShowPost.aspx?siteid=15&postid=3370339
------解决方案--------------------
1.列设置成DataGridViewComboxColumn列就行
2.cellvaluechange事件,更改单元格的值后响应的事件
------解决方案--------------------
http://www.cnblogs.com/lqss20/archive/2008/03/31/DataGridView.html
给txtbox添加
Keypress
------解决方案--------------------
DataTable dt = new DataTable(); dt.Columns.Add("vName"); dt.Columns.Add("sCode"); sSortId.DataSource = dt; sSortId.DisplayMember = "vName"; sSortId.ValueMember = "sCode";
------解决方案--------------------
已解决,给分