How can I know where Am i in a RichTextBox?

DevilAkuma

Active member
Joined
Oct 24, 2005
Messages
37
Programming Experience
Beginner
Hello!

My problem is this: I've some words in a richTextBox. I want that when I over them a minipanel appear (that contains a little explanation about the word) Like a typical tooltipo, more or less.

So, I've been triying to do it, but I can't. I wanted to do it with the MouseHover event, but I don't know where my mouse pointer is :(
Is any way to do it?

Thanks in advance!
 
Check this code out:
VB.NET:
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] RichTextBox1_MouseMove([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.MouseEventArgs) _
[/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] RichTextBox1.MouseMove
[/SIZE][SIZE=2][COLOR=#0000ff] Me[/COLOR][/SIZE][SIZE=2].Text = [/SIZE][SIZE=2][COLOR=#800000]"'"[/COLOR][/SIZE][SIZE=2] & getword(RichTextBox1.Text, RichTextBox1.GetCharIndexFromPosition(e.Location)) & [/SIZE][SIZE=2][COLOR=#800000]"'"
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][SIZE=2] getword([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] text [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] ix [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Dim[/COLOR][/SIZE][SIZE=2] ix1, ix2 [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] For[/COLOR][/SIZE][SIZE=2] ix1 = ix [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] text.Length - 1
[/SIZE][SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][SIZE=2] text(ix1) = [/SIZE][SIZE=2][COLOR=#800000]" " [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Exit [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]For
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Next
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] For[/COLOR][/SIZE][SIZE=2] ix2 = ix [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] 0 [/SIZE][SIZE=2][COLOR=#0000ff]Step[/COLOR][/SIZE][SIZE=2] -1
[/SIZE][SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][SIZE=2] text(ix2) = [/SIZE][SIZE=2][COLOR=#800000]" " [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Exit [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]For
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Next
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] If[/COLOR][/SIZE][SIZE=2] ix2 = -1 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2] ix2 = 0
[/SIZE][SIZE=2][COLOR=#0000ff] Return[/COLOR][/SIZE][SIZE=2] text.Substring(ix2, ix1 - ix2).Trim([/SIZE][SIZE=2][COLOR=#0000ff]New [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Char[/COLOR][/SIZE][SIZE=2]() {[/SIZE][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"."[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]","[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]":"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]";"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"?"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"!"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"("[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]")"[/COLOR][/SIZE][SIZE=2]})
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Function
[/COLOR][/SIZE]
 
I tried this code but I recieve the following error in the underlined expression

Expression is not an array or a method, and cannot have an argument list.

If text(ix1) = " " Then Exit For

If text(ix2) = " " Then Exit For
 
It is VB.Net 2.0 code, I use the default property Chars, so in Net1 you can do 'text.Chars(ix)'. Also in Mousemove .Net1 haven't got 'e.location' but there is 'e.X' and 'e.Y' that you can create a new Point from.

Please let your user profile express your Primary .Net Platform or express it yourself..
 
Back
Top