kuhaku kuhaku - 4 months ago 36
C# Question

Bind a PictureBox with a string of a url for LoadAsync

Is there a way to bind a PictureBox to a string so that when the string will change, it will call

with the url in the string and load an image?

Currently this is what I have in the auto generated code.

this.itemImagePictureBox.DataBindings.Add(new System.Windows.Forms.Binding("Image", this.MySource, "ItemImage", true));

What I want instead is:

this.itemImagePictureBox.DataBindings.Add(new System.Windows.Forms.Binding("String", this.MySource, "ImageUrl", true));

has a property for url string, and I also tried to make it have a field of an
, but a
for example doesn't have a load async feature so I still can't use the url string.


Make sure the WaitOnLoad property is false (default), thus enabling asynchronous image load, and then bind to ImageLocation property:

this.itemImagePictureBox.WaitOnLoad = false;
this.itemImagePictureBox.DataBindings.Add(new System.Windows.Forms.Binding(
    "ImageLocation", this.MySource, "ImageUrl", true));