Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- int selstart = textBox1.SelectionStart;
- //get previous newline...
- int linestart = textBox1.Text.LastIndexOf(Environment.NewLine,selstart);
- if (linestart == -1) linestart = 0; else linestart += Environment.NewLine.Length;
- int lineend = textBox1.Text.IndexOf(Environment.NewLine, selstart);
- if(lineend==-1) lineend = textBox1.Text.Length;
- String theline = textBox1.Text.Substring(linestart, lineend - linestart);
- Debug.Print("line was: " + theline);
- //select the line...
- textBox1.SelectionStart = linestart;
- textBox1.SelectionLength = theline.Length;
- textBox1.SelectedText = "#" + theline;
- textBox1.SelectionStart = selstart + 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement