0

Hi, I'm writing a chat application in C# and I want to ask how I can insert pictures into textBox or richTextBox , you know, just something like this ;)

Thanx, Stivi (EU)

3
Contributors
2
Replies
5
Views
12 Years
Discussion Span
Last Post by Mayo
0

There is a method in textBox called CopyPicture();
Can be used without parameters or you can
instert a parameter of XlPictureAppearance type.
Sorry dont know any more hope this helps....

0

Hay man if u are still looking for a way to insert images into a TextBox here is a way. Just execute the following method.
PS: It uses a "RichTextBox"

public void InsertImage(string pic)  
        {
            //string lstrFile = fileDialog.FileName;
            string lstrFile = pic;
            Bitmap myBitmap = new Bitmap(lstrFile);
            // Copy the bitmap to the clipboard.
            Clipboard.SetDataObject(myBitmap);
            // Get the format for the object type.
            DataFormats.Format myFormat = DataFormats.GetFormat (DataFormats.Bitmap);
            // After verifying that the data can be pasted, paste
            if(richTextBox1.CanPaste(myFormat)) 
            {
                richTextBox1.Paste(myFormat);
            }
            else 
            {
                MessageBox.Show("The data format that you attempted site" + 
                    " is not supportedby this control.");
            }
            
        }

The only problem is that it loads the image into the clipboard before loadong it into the
textbox, please note!!!!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.