views:

214

answers:

2

Hey,

I'm trying to make some sort of intellisense look a like for an editor I'm working on. When the user types in the richtextbox and the letters match a word a listview will pop-up and the matched word will be selected.

the problem is the focus is still on the richtextbox so all the key presses will go to that control, which is good, except that if there's a match I need the Return and arrow keys to trigger in the listview and not in the richtextbox.

is there some way of using the keypress event of the richtextbox to send those keys to the listview?

thanks

+1  A: 

Would it not be easier to use scintilla, the .NET wrapper can be found here, which would do all of what you are looking for?

Edit: It looks like someone has done this, in what you are trying to achieve, an article about it is on CodeProject.

Hope this helps, Best regards, Tom.

tommieb75
I guess so, but I'm more of doing this for learning purposes, and I can't figure out how to do it.I'll look into scintilla, but I still hope someone has a solution for this.thanks though.
Restart
nice,that article is pretty helpfull, thanks man.
Restart
A: 

I think it is good that the focus remains on the richtextbox.

How about subclassing that listview to add methods like void SelectNext(), void SelectPrevious(), and string PerformCompletion(). You handle mouse events only for the richtextbox. If the textbox is visible, and the user presses a down arrow, call SelectNext() and swallow the keypress, but if it is not visible, just navigate down to the next line (let the keypress through).

If the listview is visible and the user presses Enter or Tab or . or whatever, call PerformCompletion() to get the selected string, then add whatever characters haven't already been entered.

Jay