RTF document editor
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
Hello,
I was just going through my project folder and found this document editor I was working on some time ago. Its only basic but may help you if you want to make a text editor.
![Image]()
Features include:
Save & Load as *.rtf file (saves font/sizes/colour etc rather than just plain text)
Change text colour
Change text font/size
Change font style
Here is how to make this little application. First you will need to add the following controls to your form:
MenuStrip - add 3 fields into this control "Save"..."Load"...and "Exit"
14 Buttons
1 RichtextBox
Button 1 - 5 = Used to select font style
Buttons 6 - 14 = Used to select colours
Button 15 = Choose font
OK once you have done that and arranged the controls as you want them you need to stretch out the richtextbox so it fits most of the form, make it nice and big.
Then you can simply copy and paste this code over:
If everything went ok you should now be able to run and use your basic text editor
.
Source-Code: Happy coding cooll;
I was just going through my project folder and found this document editor I was working on some time ago. Its only basic but may help you if you want to make a text editor.

Features include:
Save & Load as *.rtf file (saves font/sizes/colour etc rather than just plain text)
Change text colour
Change text font/size
Change font style
Here is how to make this little application. First you will need to add the following controls to your form:
MenuStrip - add 3 fields into this control "Save"..."Load"...and "Exit"
14 Buttons
1 RichtextBox
Button 1 - 5 = Used to select font style
Buttons 6 - 14 = Used to select colours
Button 15 = Choose font
OK once you have done that and arranged the controls as you want them you need to stretch out the richtextbox so it fits most of the form, make it nice and big.
Then you can simply copy and paste this code over:
Code: Select all
Public Class Form1
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
RichTextBox1.SelectionColor = Color.LightSlateGray
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RichTextBox1.SelectionFont = New Font(Me.RichTextBox1.SelectionFont, FontStyle.Bold)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RichTextBox1.SelectionFont = New Font(Me.RichTextBox1.SelectionFont, FontStyle.Regular)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
RichTextBox1.SelectionFont = New Font(Me.RichTextBox1.SelectionFont, FontStyle.Italic)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
RichTextBox1.SelectionFont = New Font(Me.RichTextBox1.SelectionFont, FontStyle.Strikeout)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
RichTextBox1.SelectionFont = New Font(Me.RichTextBox1.SelectionFont, FontStyle.Underline)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
RichTextBox1.SelectionColor = Color.Red
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
RichTextBox1.SelectionColor = Color.Blue
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
RichTextBox1.SelectionColor = Color.Purple
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
RichTextBox1.SelectionColor = Color.Black
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
RichTextBox1.SelectionColor = Color.Pink
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
RichTextBox1.SelectionColor = Color.Yellow
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
RichTextBox1.SelectionColor = Color.Green
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
RichTextBox1.SelectionColor = Color.Orange
End Sub
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
Dim savefiledialog1 As New SaveFileDialog
savefiledialog1.Title = "Save File"
savefiledialog1.FileName = "*.rtf"
savefiledialog1.Filter = "RTF |*.rtf"
If savefiledialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
RichTextBox1.SaveFile(savefiledialog1.FileName, RichTextBoxStreamType.RichText)
End If
End Sub
Private Sub LoadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadToolStripMenuItem.Click
Dim openfiledialog1 As New OpenFileDialog
openfiledialog1.Title = "Save File"
openfiledialog1.FileName = "*.rtf"
openfiledialog1.Filter = "RTF |*.rtf"
If openfiledialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
RichTextBox1.LoadFile(openfiledialog1.FileName, RichTextBoxStreamType.RichText)
End If
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
Dim fontdialog1 As New FontDialog
If fontdialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
RichTextBox1.SelectionFont = fontdialog1.Font
End If
End Sub
End Class
If everything went ok you should now be able to run and use your basic text editor

Source-Code: Happy coding cooll;
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
wow come on i would have put a tutorial up but u already have.
And i like the colour thing i guess
And i like the colour thing i guess
Hi Codenstuff
Wow i missed this little Gem
Cheers fella, as always quality apps from da man
** I have used this code and modified it slightly here and there to create the CnSDesktop RTF Editor**
Chris
Wow i missed this little Gem

Cheers fella, as always quality apps from da man

** I have used this code and modified it slightly here and there to create the CnSDesktop RTF Editor**

Chris
Last edited by hungryhounduk on Fri Feb 19, 2010 11:52 am, edited 1 time in total.
Hello codenstuff,
Its a cool wordpad to be a beginner's one. But when I click the bold button, the text is bold and when I click the italic button, the text is italic. But it doesn't becomes bold and italic at one time. Isn't it possible that the fontstyle buttons behave like a real wordpad? Please reply.
Thank you.
Its a cool wordpad to be a beginner's one. But when I click the bold button, the text is bold and when I click the italic button, the text is italic. But it doesn't becomes bold and italic at one time. Isn't it possible that the fontstyle buttons behave like a real wordpad? Please reply.
Thank you.
Try this usman:
This is for italic button
This is for italic button
Code: Select all
An this is for the bold button
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont.FamilyName, RichTextBox1.SelectionFont.FontStyle Or FontStyle.Italic)
Code: Select all
I have never tested it, you might have to edit a little.RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont.FamilyName, RichTextBox1.SelectionFont.FontStyle Or FontStyle.Bold)
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

Well this tutorial was just a quicky to demonstrate font selections you will probably need to add a function somewhere that checks if a specific font style is activated..like if you click the bold button and if you then want it to be italic aswell you will need to check if bold is already active. Or something like that lol.
You could do it in one button like:
You could do it in one button like:
Code: Select all
RichTextBox1.SelectionFont = New Font(Me.RichTextBox1.SelectionFont, FontStyle.Bold + FontStyle.Italic)
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Copyright Information
Copyright © Codenstuff.com 2020 - 2023