TextBox 控件 C# 中的图像
Image inside a TextBox Control C#
我有一个带有文本框的 Windows 表单,我想将一些文本连同里面的图像一起发送到消息的收件箱列表。
对于图像的预览,我使用了 javascript。图像的选择是通过 FileUpload 完成的。 Like this preview function.
我想将此图像上传到 TextBox 并将其保存在我的数据库中。
有没有办法包含此图像。我只见过 RichTextBox。
拖放怎么样???
This TextBox is with a button included
您可以 做的是向显示图像的文本框添加控件。
Label imgLabel = new Label();
imgLabel.Image = Image.FromFile(somefile);
imgLabel.AutoSize = false;
imgLabel.Size = imgLabel.Image.Size;
imgLabel.ImageAlign = ContentAlignment.MiddleCenter;
imgLabel.Text = "";
imgLabel.BackColor = Color.Transparent;
imgLabel.Parent = textBox1;
// pick a location where it won't get in the way too much
imgLabel.Location = new Point(textBox1.ClientSize.Width - imgLabel.Image.Width, 0);
图片会浮在文字上方,遮住文字挡路:-(
你不能做的是
- 将该控件放在
TextBox
的文本后面。我不知道在 Winforms
中有任何 Control
可以做到这一点; TextBox
和 RichTextBox
都不支持透明度,唉..
- 在文本中嵌入图像并让它围绕它流动。为此,您需要使用
RichTextBox
!
我有一个带有文本框的 Windows 表单,我想将一些文本连同里面的图像一起发送到消息的收件箱列表。 对于图像的预览,我使用了 javascript。图像的选择是通过 FileUpload 完成的。 Like this preview function. 我想将此图像上传到 TextBox 并将其保存在我的数据库中。 有没有办法包含此图像。我只见过 RichTextBox。 拖放怎么样???
This TextBox is with a button included
您可以 做的是向显示图像的文本框添加控件。
Label imgLabel = new Label();
imgLabel.Image = Image.FromFile(somefile);
imgLabel.AutoSize = false;
imgLabel.Size = imgLabel.Image.Size;
imgLabel.ImageAlign = ContentAlignment.MiddleCenter;
imgLabel.Text = "";
imgLabel.BackColor = Color.Transparent;
imgLabel.Parent = textBox1;
// pick a location where it won't get in the way too much
imgLabel.Location = new Point(textBox1.ClientSize.Width - imgLabel.Image.Width, 0);
图片会浮在文字上方,遮住文字挡路:-(
你不能做的是
- 将该控件放在
TextBox
的文本后面。我不知道在Winforms
中有任何Control
可以做到这一点;TextBox
和RichTextBox
都不支持透明度,唉.. - 在文本中嵌入图像并让它围绕它流动。为此,您需要使用
RichTextBox
!