有没有个高手帮我看下C#里面的datagridview怎么使用

来源:百度知道 编辑:UC知道 时间:2024/05/17 01:42:01
我已经定好了物品编码,在销售的datagrid或者datagridview中怎么利用编码来销售
例如:可口可乐物品编码是kkkl,我在销售时的那个datagrid中打K,下面的那个datagridview中显示所有编码开头为K的商品,输入kkkl敲回车在下面的表中选择好商品后再敲回车,则该商品的一些基本信息显示在上面的datagrid中(上面的这个datagrid物品编码是可以编辑的)
有没有高手做过类似的产品,给个代码参考参考,或者不用datagrid用其它的也行,VS2005C#
上面的那个表格是可以输入多行的,保存后计算出所有价格
我想要段代码,或者是控件,不知道哪位大大有

这是我之前整理的知识,希望对你有帮助吧,
最常见的数据绑定:
string sqlStr=数据库查询语句;
DataManager db = new DataManager();
DataSet ds = db.ExcuteSelectCmd(sqlStr);
DataGridView.DataSource = ds.Tables[0];
对DataGridViewCheckBoxColumn列进行动态添加,赋值,判定选中
添加:
DataGridViewCheckBoxColumn select = new DataGridViewCheckBoxColumn();
select.HeaderText = " 选择";
select.Width = 100;
dataGridView1.Columns.Insert(0, select);//添加到dataGridView
赋值:
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells[0];
chk.Value=true;

}

控制其显示状况即当.Value = false时显示为未