dodger_web wrote:
Hi,
I don't want to use winforms at all.
The autocomplétion feature must apply to the console output.
let's say you type in the console "show conf".
If the user press a specific key (tab), i want my code to autocomplete
"show conf" by "show config".
Regards
nick_nw a écrit :
If I understand your requirements you want to present the user with a
text entry window and offer simple auto completion?
You could use a rich text box and write some code that gets called when
the KeyPress event is fired. The code would scan back to the start of
a line or a space, extract the start of the word the user has entered,
and then find all words in a list of supported commands that start with
that text.
Let me know if this is the sort of thing you're after. Really though
it should be quite simple, have a play with the KeyPress and KeyDown
(to get a tab press) events.
Nick
http://seecharp.blogspot.com/
The principles are still the same. This code is the start of a very
simplistic solution to your problem:
string [] words = new string [] { "show conf", "list things", "do" };
StringBuilder sb = new StringBuilder ();
while (true)
{
ConsoleKeyInfo cki = Console.ReadKey (false);
if (cki.Key == ConsoleKey.Tab)
{
// Look up word in the words list amd write remaining text
to console.
}
else
{
// Add the typed in key to the string builder.
sb.Append (cki.KeyChar.ToString ());
}
}
Obviously a lot of scope for improvement, but the gist is there. Let
me know how you get on.
By the way is this a work project/college uni/or just your own
interest?
Best,
Nick
http://seecharp.blogspot.com/