views:

113

answers:

2

I'm trying to make something like a textbox for a console application, how to limit the Console.In to only read a defined count of characters from user inputs ?

EDIT

I can't go the Readkey() loop -way, i still need to interact with that box, like using the arrow keys to navigate left an right, Del or Backspace to edit the input and some some keys for validation. ReadKey is printing those key as a " " (space) and i can't rely on counting on how many key are pressed since Overtyping may occur (and in this project, we need overtyping ! )

Im thinking of something like reading from the buffer at a specified location and set the cursor to an another location when that field max lengh is reached. can it be done this way ?

what are my chances ? i really need your help

+1  A: 

You can't set limitations on Console.ReadLine() etc. But you can make loop Console.ReadLine() for example and validate input in it.

Andrew
A: 

You can call ReadKey in a loop and pass true to prevent echo.

SLaks
Actually you have pass (Intercept=) **true**. And handle cursor, backspace, delete etc
Henk Holterman
i've edited my post, but i still need the use backspace and delete keys, ReadKey() will only echo them or reject them
metro