Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

How do i set a variable that will hold the last char or letter ?

$
0
0

This is the code:

private void richTextBox1_MouseMove(object sender, MouseEventArgs e)
        {
            int positionToSearch = richTextBox1.GetCharIndexFromPosition(new Point(e.X, e.Y));
            richTextBox1.SelectionStart = positionToSearch;
            richTextBox1.SelectionLength = 1;
            richTextBox1.SelectionColor = Color.Red;
        }

I move the mouse over the text and its painting/coloring the current char/letter in Red.

I want to keep to hold the last one char/letter before in a variable. 

For example if the mouse was over a letter: B

Now B is in red now i move the mouse over a letter: D

So now D is in red now i want that i will have a variable int type like positionToSearch that will hold the position of B

Then i moved from D to Y so the variable will hold now the position of D.



Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>