【发布时间】:2012-07-15 11:09:36
【问题描述】:
我想做的是将包含图像的列添加到 DataTable。创建列/行后,DataTable 将作为 DataGrid 的源。
我尝试了 resolveUrl 方法,但没有成功。
您能帮我在我的数据表中添加一个图像列吗?
【问题讨论】:
标签: c# image datagrid datatable
我想做的是将包含图像的列添加到 DataTable。创建列/行后,DataTable 将作为 DataGrid 的源。
我尝试了 resolveUrl 方法,但没有成功。
您能帮我在我的数据表中添加一个图像列吗?
【问题讨论】:
标签: c# image datagrid datatable
DataTable table = new DataTable("ImageTable"); //Create a new DataTable instance.
DataColumn column = new DataColumn("MyImage"); //Create the column.
column.DataType = System.Type.GetType("System.Byte[]"); //Type byte[] to store image bytes.
column.AllowDBNull = true;
column.Caption = "My Image";
table.Columns.Add(column); //Add the column to the table.
然后你可以这样设置MyImage列
DataRow row = table.NewRow();
row["MyImage"] = <Image byte array>;
tables.Rows.Add(row);
【讨论】: