先用程式把一個PictureEdit控制項放入GridControl裡面

放入了PictureEdit控制項後,設定一下就可以在Grid裡顯示圖片

//DataTable加入一個欄位為byte[]型態的

myDataTable.Columns.Add("F_Icon",typeof(byte[]));

//然後把byte[]型態的值寫到此欄位中

//接下來開始寫

DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit F_Icon_Edit = new DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit();

gridControl1.RepositoryItems.Add(F_Icon_Edit);

(gridControl1.MainView as DevExpress.XtraGrid.Views.Grid.GridView).Columns["F_Icon"].ColumnEdit = F_Icon_Edit;

//下面這行是如果DataSource是資料庫的話,直接指定資料庫的欄位去繫結

//(whichGrid.MainView as DevExpress.XtraGrid.Views.Grid.GridView).Columns["F_Icon"].FieldName = "F_Icon";

F_Icon_Edit.PictureStoreMode = DevExpress.XtraEditors.Controls.PictureStoreMode.ByteArray;

F_Icon_Edit.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom;


不過DataTable放太多圖片的話記憶體就爆了=.="

welkingunther 發表在 痞客邦 PIXNET 留言(0) 人氣()