首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powerpacks DataRepeater控件-图片框中未加载图像

Powerpacks DataRepeater控件-图片框中未加载图像
EN

Stack Overflow用户
提问于 2012-02-05 20:28:01
回答 2查看 1.2K关注 0票数 0

我有一个winform powerpack datareapter控件,里面有一个图片框。这是来自类的代码片段。

DisplaySystemUsersControl.Designer.cs

代码语言:javascript
复制
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

代码语言:javascript
复制
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

代码语言:javascript
复制
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; }
}

正在加载用户ID和用户名。但图像未加载。SystemUserEntity_Only_For_UI_Binding.User_Image()保存图像字节数组。

有人能告诉我出了什么问题吗?

EN

回答 2

Stack Overflow用户

发布于 2012-02-06 02:32:30

你的类应该看起来像这样:

代码语言:javascript
复制
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; }
}

字节数组需要在代码中的某处转换为图像:

代码语言:javascript
复制
using (MemoryStream ms = new MemoryStream(imgBytes)) {
  this.User_Image = Image.FromStream(ms);
}
票数 0
EN

Stack Overflow用户

发布于 2015-09-12 19:38:42

代码语言:javascript
复制
public void BindRepeater (DataSet dsObj)
{
   pictureBox1.DataBindings.Clear();
   pictureBox1.DataBindings.Add("ImageLocation", dt, "Photo");
   dataRepeater1.DataSource = dsObj;

 }
票数 -3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9149219

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档