Bonjour tout le monde, après diverses recherchers concernant l'insertion d'image dans une richtextbox et après avoir trouvé une fonction le faisant.
La voici :
Je la comprends... mais une chose m'échappe. Lorsque j'essaie de mettre un png, un jpg, un bmp ... marche jamais ^^.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public void InsertImage(string pic) { <div style="margin-left:40px">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)) { <div style="margin-left:40px"> associateRichBox.Paste(imgFormat);</div> } else { <div style="margin-left:40px">MessageBox.Show("The data format provided is not supported by this control.");</div> }</div> }
Donc faut-il régler ma richtextbox afin qu'elle accepte le "paste"?
Partager