-
Apr 26th, 2015, 06:07 AM
#1
Thread Starter
Member
[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
Last edited by DJ_Warp; Apr 26th, 2015 at 06:54 AM.
-
Apr 26th, 2015, 07:58 AM
#2
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).
- If my post helped you, please Rate it
- If your problem is solved please also mark the thread resolved
I use VS2015 (unless otherwise stated).
_________________________________________________________________________________
B.Sc(Hons), AUS.P, C.Eng, MIET, MIEEE, MBCS / MCSE+Sec, MCSA+Sec, MCP, A+, Net+, Sec+, MCIWD, CIWP, CIWA
I wrote my very first program in 1979, using machine code on a mechanical Olivetti teletype connected to an 8-bit, 78 instruction, 1MHz, Motorola 6800 multi-user system with 2k of memory. Using Windows, I dont think my situation has improved.
-
Apr 26th, 2015, 12:44 PM
#3
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/
-
Apr 26th, 2015, 03:08 PM
#4
Thread Starter
Member
Re: [RESOLVED] C# Console List Selector
Thank you Bulldog, works brilliantly.
BenJones - Will read through it, looks interesting
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|