Powerpacks DataRepeater Control - 图像未加载到图片框中

发布于 2025-01-02 19:36:40 字数 1816 浏览 2 评论 0原文

我有一个带有图片框的 winform powerpacks datareapter 控件。这是类中的代码片段。

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; }
}

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

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

I have a winform powerpacks datareapter control having a picture box. This is the code snippet from the classes.

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; }
}

User ID and User name is getting loaded. But Image is not getting loaded. SystemUserEntity_Only_For_UI_Binding.User_Image() is holding the image byte array.

Can anybody please tell me what is going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

几度春秋 2025-01-09 19:36:40

您的类应该如下所示:

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);
}

Your class should look something like this:

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; }
}

The byte array needs to be translated into an image somewhere in your code:

using (MemoryStream ms = new MemoryStream(imgBytes)) {
  this.User_Image = Image.FromStream(ms);
}
小霸王臭丫头 2025-01-09 19:36:40
public void BindRepeater (DataSet dsObj)
{
   pictureBox1.DataBindings.Clear();
   pictureBox1.DataBindings.Add("ImageLocation", dt, "Photo");
   dataRepeater1.DataSource = dsObj;

 }
public void BindRepeater (DataSet dsObj)
{
   pictureBox1.DataBindings.Clear();
   pictureBox1.DataBindings.Add("ImageLocation", dt, "Photo");
   dataRepeater1.DataSource = dsObj;

 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文