Powerpacks DataRepeater Control - изображение не загружается в графическом окне - PullRequest
0 голосов
/ 05 февраля 2012

У меня есть элемент управления переносом данных winform powerpacks с графическим блоком.Это фрагмент кода из классов.

DisplaySystemUsersControl.Designer.cs

this.picBoxUserImage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.picBoxUserImage.DataBindings.Add(new System.Windows.Forms.Binding("Image", this.UserBindingSource, "User_Image", true));
this.picBoxUserImage.Location = new System.Drawing.Point(3, 3);
this.picBoxUserImage.Name = "picBoxUserImage";
this.picBoxUserImage.Size = new System.Drawing.Size(100, 93);
this.picBoxUserImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picBoxUserImage.TabIndex = 0;
this.picBoxUserImage.TabStop = false;
this.picBoxUserImage.Click += new System.EventHandler(this.picBoxUserImage_Click);

DisplaySystemUsersControl.cs

public DisplaySystemUsersControl()
{
    InitializeComponent();
    this.dataRepeaterAccounts.DataSource = this.UserBindingSource;
    LoadAccountData();
}    

private void LoadAccountData()
{
    SystemUserBusinessClass oSystemUserBusinessClass = new SystemUserBusinessClass();
    List<SystemUserEntity_Only_For_UI_Binding> obj = oSystemUserBusinessClass.GetSystemUsersForUI();

    BindingSource tempUserBindingSource = (BindingSource)dataRepeaterAccounts.DataSource;
    obj.ForEach(oSystemUserEntity_Only_For_UI_Binding => tempUserBindingSource.Add(oSystemUserEntity_Only_For_UI_Binding));
}

SystemUserEntity_Only_For_UI_Binding.cs

public class SystemUserEntity_Only_For_UI_Binding
{
    public string User_Id { get; set; }

    public string User_Name { get; set; }

    public byte[] User_Image { get; set; }
}

Идентификатор пользователя и имя пользователя загружаются.Но изображение не загружается.SystemUserEntity_Only_For_UI_Binding.User_Image() содержит байтовый массив изображения.

Может кто-нибудь сказать мне, что идет не так?

Ответы [ 2 ]

0 голосов
/ 12 сентября 2015
public void BindRepeater (DataSet dsObj)
{
   pictureBox1.DataBindings.Clear();
   pictureBox1.DataBindings.Add("ImageLocation", dt, "Photo");
   dataRepeater1.DataSource = dsObj;

 }
0 голосов
/ 05 февраля 2012

Ваш класс должен выглядеть примерно так:

public class SystemUserEntity_Only_For_UI_Binding
{
  public string User_Id { get; set; }
  public string User_Name { get; set; }
  public Image User_Image { get; set; }
}

Массив байтов необходимо преобразовать в изображение где-то в вашем коде:

using (MemoryStream ms = new MemoryStream(imgBytes)) {
  this.User_Image = Image.FromStream(ms);
}
...