RTF Document Editor
All tutorials created in C# to be posted in here.
7 posts
Page 1 of 1
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.
This is the same as my other tutorial in VB.Net and I have just converted it for any C# users who may want it.
![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. Its mostly button code so its easy to follow, each one changes Font/Color/Style:
If everything went ok you should now be able to run and use your basic text editor
.
Source: 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.
This is the same as my other tutorial in VB.Net and I have just converted it for any C# users who may want it.

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. Its mostly button code so its easy to follow, each one changes Font/Color/Style:
Code: Select all
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
namespace DocPad
{
public partial class Form1
{
internal Form1()
{
InitializeComponent();
}
private void Button11_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.LightSlateGray;
}
private void Button1_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionFont = new Font(this.RichTextBox1.SelectionFont, FontStyle.Bold);
}
private void Button2_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionFont = new Font(this.RichTextBox1.SelectionFont, FontStyle.Regular);
}
private void Button3_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionFont = new Font(this.RichTextBox1.SelectionFont, FontStyle.Italic);
}
private void Button4_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionFont = new Font(this.RichTextBox1.SelectionFont, FontStyle.Strikeout);
}
private void Button5_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionFont = new Font(this.RichTextBox1.SelectionFont, FontStyle.Underline);
}
private void Button6_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.Red;
}
private void Button7_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.Blue;
}
private void Button8_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.Purple;
}
private void Button9_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.Black;
}
private void Button10_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.Pink;
}
private void Button12_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.Yellow;
}
private void Button13_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.Green;
}
private void Button14_Click(object sender, System.EventArgs e)
{
RichTextBox1.SelectionColor = Color.Orange;
}
private void SaveToolStripMenuItem_Click(object sender, System.EventArgs e)
{
SaveFileDialog savefiledialog1 = new SaveFileDialog();
savefiledialog1.Title = "Save File";
savefiledialog1.FileName = "*.rtf";
savefiledialog1.Filter = "RTF |*.rtf";
if (savefiledialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
RichTextBox1.SaveFile(savefiledialog1.FileName, RichTextBoxStreamType.RichText);
}
}
private void LoadToolStripMenuItem_Click(object sender, System.EventArgs e)
{
OpenFileDialog openfiledialog1 = new OpenFileDialog();
openfiledialog1.Title = "Save File";
openfiledialog1.FileName = "*.rtf";
openfiledialog1.Filter = "RTF |*.rtf";
if (openfiledialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
RichTextBox1.LoadFile(openfiledialog1.FileName, RichTextBoxStreamType.RichText);
}
}
private void ExitToolStripMenuItem_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void Button15_Click(object sender, System.EventArgs e)
{
FontDialog fontdialog1 = new FontDialog();
if (fontdialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
RichTextBox1.SelectionFont = fontdialog1.Font;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
} //end of root namespace
If everything went ok you should now be able to run and use your basic text editor

Source: 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.
are you beginning to venture from VB?
nice and i guarantee this will help me learn it
nice and i guarantee this will help me learn it
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

Hmmm... Wordpad in C#? I remember when you posted this. This was what made me to make my own editor. Do it in C++ lol.
zachman61 wrote:are you beginning to venture from VB?I think he just used a converter, but he may very well have actually did the whole conversion process himself.
nice and i guarantee this will help me learn it
7 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023