DataPropertyName在另一列上使用

时间:2014-04-29 20:05:53

标签: 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 ds = new DataSet();
da.Fill(ds, "customers");

好的,执行此操作后我禁用了AutoGenerateColumns,我设置了DataSource,最后我手动创建了列。

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"

0 个答案:

没有答案