I have a Windows Form with a TextBox and I would like to send some text together with an image inside to a Inbox list of messages. For the preview of the image, I used javascript. Selection of the image is done with FileUpload. Like this preview function. I want to upload this image to the TextBox and save it in my database. Is there a way to include this image. I have only seen RichTextBox. What about drag and drop???
This TextBox is with a button included

What you can do is add a Control to the TextBox, which shows an Image.
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);

The image will float above the text, cover it and get in the way :-(
What you can't do is
TextBox's text. I don't know of any Control that can do that in Winforms; both TextBox and RichTextBox do not support transparency, alas..RichTextBox!If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With