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