Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#将图像属性添加到controlbox_C# - Fatal编程技术网

C#将图像属性添加到controlbox

C#将图像属性添加到controlbox,c#,C#,My userControl1.cs包含一个文本框和一个图片框 如何向类添加属性以允许它从url字符串获取图片 这就是我目前所拥有的 public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } public override string Text { get {

My userControl1.cs包含一个文本框和一个图片框 如何向类添加属性以允许它从url字符串获取图片

这就是我目前所拥有的

    public partial class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
    }

    public override string Text
    {
        get
        {
            return textBox1.Text;
        }

        set
        {
            textBox1.Text = value;
        }
    }

}

这就是添加属性的方式

public Image PictureFromWeb  { get; set;}
但有更好的办法

内置方法“将ImageLocation设置为指定的URL并显示指示的图像。”(自.NetFramework 2)

引用自--Upvote他的答案

因此我试图让用户控件中的图片框获取url并将其转换为图片,我使用userControl11.UserPicture=tweet.Creator.DownloadProfileImage(令牌);DownloadProfileImage检索url字符串。我将FamilyPicture更改为UserPicture