|
-
September 25th, 2008, 07:12 AM
#1
textBox controlling content
Hi,
I would like to be able to controll posibility of getting to the next line by typing Enter only when the current line of the multiline textbox has 10 characters. Is it possible,
thank you for help.
-
September 25th, 2008, 08:05 AM
#2
Re: textBox controlling content
Please clarify yourself, what do you mean by "getting the next line"?
-
September 25th, 2008, 08:25 AM
#3
Re: textBox controlling content
I mean move to the next line by typing enter.
For example i write 123456 and then type enter. In result cursor should stay in the same position, not move to the next line (new line) but when i type for example 1234567890 then in the current line we do have 10 characters ane after "enter" cursor in textbox should move to the next line starting new line. I hope that its clear now if not please let me know, english is my forign language so i do know that i may be understood in wrong way.
thanks for help
-
September 29th, 2008, 03:11 AM
#4
Re: textBox controlling content
Any hint here?
Mayby my dexcription is still inclear and you want me to try to describe it in different way hmm ?
-
September 29th, 2008, 03:53 AM
#5
Re: textBox controlling content
I got it what you are trying to say, Just try to write down the logic by using the following line in the Key_Down event.
Code:
e.SuppressKeyPress = true;
with this, you can supress keystroke - just write down the condition for it.
I guess the logic is simple and would not be more than 10 lines.
Last edited by MMH; September 29th, 2008 at 04:11 AM.
-
September 29th, 2008, 04:21 AM
#6
Re: textBox controlling content
I think this should be ok!
PHP Code:
int keyCount = 1;
private void txtInput_KeyDown(object sender, KeyEventArgs e)
{
keyCount++;
if (e.KeyCode == Keys.Enter)
{
keyCount--;
if (keyCount <= 10)
e.SuppressKeyPress = true;
else
keyCount = 1;
}
}
just test it and check if it works for you..
MMH.
-
October 10th, 2008, 09:37 AM
#7
Re: textBox controlling content
thanks,
it makes sense and ofcourse works in not complicated situations.
ok other question:
why code like this:
void tbxNip_KeyPress(object sender, KeyPressEventArgs e) {
int i=0;
foreach(string line in tbxNip.Lines) {
if(line.Length >10) {
tbxNip.Lines[i] = tbxNip.Lines[i].Remove(10);
tbxNip.Lines[i] = a;
}
}
}
doesnt actually works and the line in the textBox isnt changed after that?
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
|