I am developing a notepad. I have to give line no effect in that
notepad.
I have developed a function (ShowLineNo()) which reads the richtextbox
text, splits the content when a newline is found, adds the line no to
the beginning of every string and again joins it.
here is the code....
namespace WindowsApplication43
{
public partial class Form1 : Form
{
string caption;
public Form1()
{
InitializeComponent();
caption = "Simple Pad";
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = caption;
}
/*private string GetNormalText()
{
string[] each_lines = TypePadrichTextBox.Text.Split('\n');
}*/
private void ShowLineNo()
{
int line=1;
string[] each_lines = TypePadrichTextBox.Text.Split('\n');
for (int i = 0; i < each_lines.Length; i++)
{
each_lines[i] = line.ToString() + "~" + each_lines[i];
line++;
}
TypePadrichTextBox.Text = String.Join("\n", each_lines);
}
private void TypePadrichTextBox_TextChanged(object sender,
EventArgs e)
{
ShowLineNo();
}
}
}
But everytime the function is called, control moves to the beginning
of rich text box. Can I move the control to original position. please
help..