2013-12-12 22 views
-3

我有一個表格學生,有一個以二進制形式存儲圖片的照片字段。
我想用我所有的學生照片來填充我的組合框,就像我們用所有學生的名字填充組合框一樣。如何用圖片填充imagecombobox(Devexpreess Controls)

private void populateData() 
{ 
    studentList=(from s in _ApplicationDB.Students select s).ToList(); 

     foreach (Student _record in studentList)//.OrderBy(i => i) 
     { 

      comboBoxEdit1.Properties.Items.Add(_record.Name); 
      imageComboBoxEdit1.Properties.SmallImages(_record.Photo);//error in this line 
     } 
} 
+1

你能告訴我們你嘗試過什麼? – Max

+0

你需要告訴我們你試過的東西。另外,當有人試圖幫助你時,不要求任何東西。它不會讓你到達任何地方。 – gleng

+0

嗨@MaxMommersteeg我已經做到現在。 我使用此表格代碼保存圖片 string path1 = textEditFilePath.Text; FileStream fs = new FileStream(path1,FileMode.Open,FileAccess.Read); byte [] picbytes = new byte [fs.Length]; fs.Read(picbytes,0,(int)fs.Length); record.Photo = picbytes; – waleed

回答

0

imageComboBoxEdit1.Properties.SmallImages屬性在您的情況下用作方法。您應該像這樣設置SmallImages:

imageComboBoxEdit1.Properties.SmallImage = myImageCollection; 

然後,您可以選擇一個關於所選項目的索引的圖像。

這是如何工作的詳細並很好的例子說明如下: http://documentation.devexpress.com/#windowsforms/clsDevExpressXtraEditorsImageComboBoxEdittopic

+0

如何通過圖像列表初始化ImageCollection對象 – waleed

+0

ImageCollection是一個DevExpress組件。您可以在工具箱中找到它並添加到您的表格中。你可以簡單地通過items.Add()來訪問。 – Sebi