C# 在另一列上使用的DataPropertyName
我已经厌倦了寻找,我想不出答案。也许这是不可能的C# 在另一列上使用的DataPropertyName,c#,autogeneratecolumn,C#,Autogeneratecolumn,我已经厌倦了寻找,我想不出答案。也许这是不可能的 string query = "SELECT cust.id, cust.name, cust.photo, country.description FROM customers AS cust INNER JOIN countries AS country ON country.id = cust.id_country" /* etc.. command ..*/ DataSet
string query = "SELECT cust.id, cust.name, cust.photo, country.description
FROM customers AS cust
INNER JOIN countries AS country ON country.id = cust.id_country"
/* etc.. command ..*/
DataSet ds = new DataSet();
da.Fill(ds, "customers");
好的,完成此操作后,我禁用了自动生成列
,设置了数据源
,最后手动创建列
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.DataSource = ds.Tables["customers"];
var _name = new DataGridViewTextBoxColumn() {
HeaderText = "Name",
DataPropertyName = "name"
};
var _photo = new DataGridViewImageColumn() {
HeaderText = "",
Image = new Bitmap(Application.StartupPath + "/customers/" + ????????)
};
所以,我的问题是“?”字符。如何在该位置设置cust.photo
字段?
cust.photo
检索照片的名称,类似于“ske_213f.jpg”
那么,到底是什么问题呢?为什么“ske_213f.jpg”
不适合您?我在数据库中有10行,每个用户都有一张照片。“ske_213f.jpg”就是一个例子。