如何当我改变字段的值设置在DataGridView的行单元格的值? [英] How to set values in cells of row in DatagridView when I change field value?

查看:322
本文介绍了如何当我改变字段的值设置在DataGridView的行单元格的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个赢得窗体应用程序和我被困在一个局面与数据网格视图
我究竟想要做的是,如果我进入再根据条码我想要得到的数据并填写他们一些条码的<品牌名称和项目名称和MRP和所有的code>组合框。
哪个事件应,我的工作,我怎样可以得到数据,并在此数据网格视图排满。

I am developing a win form application and i am stuck in a situation with data grid view. what i exactly want to do is, if i enter some bar code then according to the bar-code i want to get data and fill them in the the combo box of brand name and Item name and mrp and all. Which event should i work on and how can i get data and fill in this data grid-view row.

推荐答案

使用 DataGridViewComboBoxColumn.DataSource 。结果
例如你有一个类品牌

public class Brand
{
    public int32 ID {get; set;}
    public string Name {get; set;}
}

格式创建品牌的一个列表,并填充数据(来自数据库我假设)

In the form create a list of Brands and fill it with data(from database I assume)

List<Brand> _brands;
this.dgvBrandNamesColumn.DataSource = _brands;
this.dgvBrandNamesColumn.DisplayMemeber = "Name";
this.dgvBrandNamesColumn.ValueMemeber = "Name";



将数据添加到的DataGridView后结果
DataGridViewComboBoxColumn 将选择从数据源相匹配的品牌名称( _brands

After adding data to DataGridView
DataGridViewComboBoxColumn will select matched brand name from DataSource(_brands)

有关更具体的帮助,显示代码是如何用数据填充的DataGridView以及如何/从哪里得到所有品牌名称

For more specific help, show code how fill datagridview with data and how/from where you get all brands names

这篇关于如何当我改变字段的值设置在DataGridView的行单元格的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆