当我更改字段值时,如何在DatagridView的行单元格中设置值? [英] How to set values in cells of row in DatagridView when I change field value?
问题描述
我正在开发一个 win form应用程序
,而且我陷入了一个数据网格视图
的情况。
我完全想做的是,如果我输入一些条形码,那么根据条形码
我想获取数据并填写他们的组合框
的品牌名称和项目名称,mrp和all。
我应该处理哪个事件,如何获取数据并填写这个数据网格视图
行。
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
将从DataSource中选择匹配的品牌名称( _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屋!