2010-06-25 109 views
0

我有一個從哪裏檢索圖像的sqlite數據庫。我必須將這些圖像顯示到Windows數據網格中。對於綁定,我有類調用聯繫人,下面在DataGridViewImageColumn中顯示圖像從Sqlite數據庫中的[Winform]

namespace ContactManager.Core 
{ 
    public class Contacts 
    { 
     private long _id = 0; 

     public long Id 
     { 
      get { return _id; } 
      set { _id = value; } 
     } 
     private string _Name = string.Empty; 

     public string Name 
     { 
      get { return _skypeName; } 
      set { _skypeName = value; } 
     } 
     private string _displayName = string.Empty; 

     public string DisplayName 
     { 
      get { return _displayName; } 
      set { _displayName = value; } 
     } 
     private long _birthday = 0; 

     public long BirthDay 
     { 
      get { return _birthday; } 
      set { _birthday = value; } 
     } 

     private string _province = string.Empty; 

     public string Province 
     { 
      get { return _province; } 
      set { _province = value; } 
     } 
     private long _phone_home = 0; 

     public long Phone_Home 
     { 
      get { return _phone_home; } 
      set { _phone_home = value; } 
     } 
     private long _phone_mobile = 0; 

     public long Phone_Mobile 
     { 
      get { return _phone_mobile; } 
      set { _phone_mobile = value; } 
     } 

     private string _mood_text = string.Empty; 

     public string Mood_Text 
     { 
      get { return _mood_text; } 
      set { _mood_text = value; } 
     } 

     private byte[] _avatar_image = new byte[4096]; 
     public byte[] Avatar_Image 
     { 
      get{return _avatar_image;} 
      set{_avatar_image = value;} 
     } 


    } 
} 

因此,考慮我應該在這個接觸類創建什麼類型的屬性來保存圖像數據,我的第一個問題。 我正在創建datagridviewcolumns在runime。代碼是低於

DataGridViewImageColumn dgvImColAvatar = new DataGridViewImageColumn(); 
dgvImColAvatar.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; 
dgvImColAvatar.HeaderText = "Avatar"; 
dgvImColAvatar.DataPropertyName = "Avatar"; 

但是當我執行應用程序它顯示我一些TargetInvocation與NullReference異常的懷疑也。 所以請幫助我從數據庫中檢索圖像數據並使用類,屬性和集合進行綁定。在他們之間,我使用MapperBase<T>自動爲屬性賦值。

回答

相關問題