C#DataGridView中加ComboBox
来源:互联网 发布:如何做好外贸 知乎 编辑:程序博客网 时间:2024/04/30 04:09
/// <summary>
/// 给dataGridView绑定 ComboBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
DataGridViewComboBoxCell DgvCell = this.dataGridView1.Rows[e.RowIndex].Cells["Unit"] as DataGridViewComboBoxCell;//获得加入ComboBox的列
DataTable dt_com = new DataTable();
dt_com.Columns.Add("Unit", Type.GetType("System.String"));
DataRow dr = dt_com.NewRow();
dr["Unit"] = "个";
dt_com.Rows.Add(dr);
dr = dt_com.NewRow();
dr["Unit"] = "台";
dt_com.Rows.Add(dr);
dr = dt_com.NewRow();
dr["Unit"] = "套";
dt_com.Rows.Add(dr);
dr = dt_com.NewRow();
dr["Unit"] = "包";
dt_com.Rows.Add(dr);
dr = dt_com.NewRow();
dr["Unit"] = "箱";
dt_com.Rows.Add(dr);
DgvCell.DataSource = dt_com;
DgvCell.DisplayMember = "Unit";
DgvCell.ValueMember = "Unit";
}
/// 给dataGridView绑定 ComboBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
DataGridViewComboBoxCell DgvCell = this.dataGridView1.Rows[e.RowIndex].Cells["Unit"] as DataGridViewComboBoxCell;//获得加入ComboBox的列
DataTable dt_com = new DataTable();
dt_com.Columns.Add("Unit", Type.GetType("System.String"));
DataRow dr = dt_com.NewRow();
dr["Unit"] = "个";
dt_com.Rows.Add(dr);
dr = dt_com.NewRow();
dr["Unit"] = "台";
dt_com.Rows.Add(dr);
dr = dt_com.NewRow();
dr["Unit"] = "套";
dt_com.Rows.Add(dr);
dr = dt_com.NewRow();
dr["Unit"] = "包";
dt_com.Rows.Add(dr);
dr = dt_com.NewRow();
dr["Unit"] = "箱";
dt_com.Rows.Add(dr);
DgvCell.DataSource = dt_com;
DgvCell.DisplayMember = "Unit";
DgvCell.ValueMember = "Unit";
}
- C#DataGridView中加ComboBox
- DataGridView中加ComboBox
- C#dataGridView中设置ComboBox
- 在dataGridView中显示combobox
- DataGridView 中动态加入ComboBox
- DataGridView 中Combobox 重载事件
- datagridview中ComboBox的数据源
- 在DataGridView中加入combobox
- C#DataGridView加时间控件
- 在comboBox中嵌套dataGirdView ; 在dataGridView中嵌套comboBox
- datagridview combobox
- 在Visual Studio 2005的DataGridView控件中加入ComboBox下拉列表框的实现(C#)
- Visual Studio 2005的DataGridView控件中加入ComboBox下拉列表框的实现(C#)
- 在Visual Studio 2005的DataGridView控件中加入ComboBox下拉列表框的实现(C#)
- 在Visual Studio 2005的DataGridView控件中加入ComboBox下拉列表框的实现(C#)
- 在Visual Studio 2005的DataGridView控件中加入ComboBox下拉列表框的实现(C#)
- 在Visual Studio 2005的DataGridView控件中加入ComboBox下拉列表框的实现(C#)
- 在Visual Studio 2005的DataGridView控件中加入ComboBox下拉列表框的实现(C#)
- linux 查看 *.a *.so 符号表(zt)
- Quartz 2D 参考-文本
- 自定义应用层通信协议
- Ogre源码剖析 -FrameListener.frameRenderingQueued
- DB2学习记录(一)
- C#DataGridView中加ComboBox
- DB2学习记录(二)
- VI 基础命令
- C语言函数
- 揭开linux内核中container_of的神秘面纱
- SUID、SGID、STICKY简介
- 理解cookie和session机制
- 深入研究java.lang.ThreadLocal类
- access函数使用