Bonjour à tous.
Dans le cadre d'un projet je souhaiterai insérer des images dans une richtextbox.
J'ai bel et bien trouvé sur le net des informations à ce sujet... dont une procédure pour insérer une image.
La voilà :
Citation :
if (associateRichBox != null)
{
string picFile = pic;
Bitmap displayPic = new Bitmap(picFile); //S.Properties.Resources.bt1
// Copy the bitmap to the clipboard.
Clipboard.SetDataObject(displayPic);
// Get the format for the object type.
DataFormats.Format imgFormat = DataFormats.GetFormat (DataFormats.Bitmap);
// After verifying that the data can be pasted, paste
if (associateRichBox.CanPaste(imgFormat))
{
associateRichBox.Paste(imgFormat);
}
else
{
MessageBox.Show("The data format provided is not supported by this control." );
}
}
|
Je comprends la fonction ^^ mais pas comment faire accepter à ma richtextbox qu'on lui colle des images dedans.
J'ai essayé avec des png... des jpg... des bmp... rien ne passe!