[RESOLVED] C# Console List Selector
Hi Guys, I have this list on a line in the Console:
<Tutorial> <Add Event> <Edit Event> <Remove Event> <Exit>
Code:
private static void startup()
{
Console.WriteLine("Welcome to the Console Calendar. What would you like to do?");
Console.WriteLine("<Tutorial> <Add Event> <Edit Event> <Remove Event> <Exit>");
}
What I would like is to be able to use the Left and Right arrow keys to select the option the user wants. Signified by the item being underlined. EDIT: Underlined is preferred however research suggests it may not be possible. So I am open to suggestions.
Visual Example:
<Tutorial> <Add Event> <Edit Event> <Remove Event> <Exit>
I am guessing I will need a to set up some sort of keypress method for the arrow keys, but haven't a clue how to put it together to achieve what is needed.
Hope someone can help me :)
Re: C# Console List Selector
A console has no KeyPress handler, so you have to simulate that usig something like;
Code:
ConsoleKeyInfo MyKeyInfo;
do
{
MyKeyInfo= Console.ReadKey();
//MyKeyInfo.Key was pressed
}
while (MyKeyInfo.Key != ConsoleKey.E);
But console programs like this typically have a command line more like;
MYConsole (T)utorial (A)dd Event (E)dit Event (R)emove Event (C)lose
So using the loop above, it's a single key press (i.e. the user presses T, A, E, R or C and the action starts).
Re: C# Console List Selector
Have you seen this looks like something you find us full.
http://www.c-sharpcorner.com/uploadf...ox-in-C-Sharp/
Re: [RESOLVED] C# Console List Selector
Thank you Bulldog, works brilliantly.
BenJones - Will read through it, looks interesting