Mini bloc-notes :
Save :
Dim SaveFile As New SaveFileDialog
SaveFile.FileName = ""
SaveFile.Filter = "Fichier Texte (*.txt)|*.txt| Tous Les Fichiers(*.*)|*.*"
SaveFile.ShowDialog()
Try
Dim ecrire As New System.IO.StreamWriter(SaveFile.FileName)
ecrire.Write(RichTextBox1.Text)
ecrire.Close()
Catch ex As Exception
End Try
SaveFile.FileName = ""
SaveFile.Filter = "Fichier Texte (*.txt)|*.txt| Tous Les Fichiers(*.*)|*.*"
SaveFile.ShowDialog()
Try
Dim ecrire As New System.IO.StreamWriter(SaveFile.FileName)
ecrire.Write(RichTextBox1.Text)
ecrire.Close()
Catch ex As Exception
End Try
(ne pas oublier d'ajouter un savefiledialog depuis la boîte à outil)
Open :
Dim OpenFile As New OpenFileDialog
OpenFile.FileName = ""
OpenFile.Filter = "Fichier Texte (*.txt)|*.txt| Tous Les Fichiers(*.*)|*.*"
OpenFile.ShowDialog()
Try
Dim lire As New System.IO.StreamReader(OpenFile.FileName)
RichTextBox1.Text = lire.ReadToEnd
lire.Close()
Catch ex As Exception
OpenFile.FileName = ""
OpenFile.Filter = "Fichier Texte (*.txt)|*.txt| Tous Les Fichiers(*.*)|*.*"
OpenFile.ShowDialog()
Try
Dim lire As New System.IO.StreamReader(OpenFile.FileName)
RichTextBox1.Text = lire.ReadToEnd
lire.Close()
Catch ex As Exception
(ne pas oublier d'ajouter un openfiledialog depuis la boîte à outil)
Font :
FontDialog1.ShowColor = True
FontDialog1.Font = RichTextBox1.Font
FontDialog1.Color = RichTextBox1.ForeColor
If FontDialog1.ShowDialog() <> DialogResult.Cancel Then
RichTextBox1.Font = FontDialog1.Font
RichTextBox1.ForeColor = FontDialog1.Color
End If
(ne pas oublier d'ajouter un FontFileDialog depuis la boîte à outil)
Visionneuse d'image :
Bouton parcourir : Try OpenFileDialog1.Title = "Open
Picture" OpenFileDialog1.FileName = ".jpg"
OpenFileDialog1.Filter = "All files |*.*"
OpenFileDialog1.ShowDialog() PictureBox1.Image =
System.Drawing.Image.FrontFile(OpenFileDialog1.filename)
Catch ex As Exeption
End Try
Catch ex As Exeption
End Try
(ne pas oublier d'ajouter un openfiledialog depuis la boîte à outil)
Bouton sauvegarder :
Try SaveFileDialog1.Title = "Open Picture" SaveFileDialog1.FileName = ".jpg" SaveFileDialog1.Filter = "All files |*.*" SaveFileDialog1.ShowDialog() PictureBox1.Image = System.Drawing.Image.FrontFile(SaveFileDialog1.filename)
Catch ex As Exeption
Try SaveFileDialog1.Title = "Open Picture" SaveFileDialog1.FileName = ".jpg" SaveFileDialog1.Filter = "All files |*.*" SaveFileDialog1.ShowDialog() PictureBox1.Image = System.Drawing.Image.FrontFile(SaveFileDialog1.filename)
Catch ex As Exeption
End Try
(ne pas oublier d'ajouter un savefiledialog depuis la boîte à outil)
Bouton Screenshot:
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FrontImage(screenshot)
graph.CopyFrontScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.image = screenshot
Mets le projet au lieu du code (+ pratique)
RépondreSupprimer