F
farrukhqadri786
Hi!
I have an imageList and a richtextbox in a C# form. I want to insert
image from imageList into a richtextbox.
I have found the following code on net but it does'nt work.
InsertImage(EmotionsImageList.Images[0]);
public void InsertImage(Image pic)
{
//string lstrFile = fileDialog.FileName;
Bitmap myBitmap = new Bitmap(pic);
// 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
rtxtAllMessages.ReadOnly = false;
if(rtxtAllMessages.CanPaste(myFormat))
{
rtxtAllMessages.Paste(myFormat);
}
else
{
MessageBox.Show("The data format that you attempted site" +
" is not supported by this control.");
}
rtxtAllMessages.ReadOnly = true;
}
Can any one help me.
I have an imageList and a richtextbox in a C# form. I want to insert
image from imageList into a richtextbox.
I have found the following code on net but it does'nt work.
InsertImage(EmotionsImageList.Images[0]);
public void InsertImage(Image pic)
{
//string lstrFile = fileDialog.FileName;
Bitmap myBitmap = new Bitmap(pic);
// 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
rtxtAllMessages.ReadOnly = false;
if(rtxtAllMessages.CanPaste(myFormat))
{
rtxtAllMessages.Paste(myFormat);
}
else
{
MessageBox.Show("The data format that you attempted site" +
" is not supported by this control.");
}
rtxtAllMessages.ReadOnly = true;
}
Can any one help me.