aewarnick Posted March 10, 2003 Posted March 10, 2003 if((int)e.KeyCode==(int)Keys.Enter) { this.RTB.Text=""; } That does not even erase a new line in the text box, there is always one left! This is frustrating! I am confused about why it does that! Could someone help me understand and maybe even give a solution to the problem? Quote C#
*Gurus* divil Posted March 10, 2003 *Gurus* Posted March 10, 2003 Would a better solution be to set the richtextbox's Multiline property to false? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted March 10, 2003 Author Posted March 10, 2003 That would be easy to do but the user needs to be able to make see the new lines that will be made on the form. Because the text box is the same size as the labels that it is going to be on. So, they will not know where rapping is going to take place on the form if they write just one line. This seems like a wierd problem to be but I bet if you tried it you would get the same results. Quote C#
Heiko Posted March 11, 2003 Posted March 11, 2003 I can't exactly figure out what you want to do, so here comes my comment anyway: Pressing the ENTER key should send two keys ... <Carriage Return> and <Linefeed>. Maybe you're only erasing the CR? Quote .nerd
aewarnick Posted March 11, 2003 Author Posted March 11, 2003 Say this is my box: |--------- || | The line in the box is the curser. | | |______| |--------- | | || | Instead of the curser starting at the top it is there. |______| Quote C#
aewarnick Posted March 11, 2003 Author Posted March 11, 2003 Those boxes looked alot more like boxes before I posted. You will have to use your vast imagination to see them now. How would I get rid of a Line Feed? Quote C#
Heiko Posted March 11, 2003 Posted March 11, 2003 Phew, another idea first perhaps? How about grabbing the Enter-Key and setting e.handled = true. Otherwise, you could, just for curiosity's sake, check if the last char in the text is chr(10) [CR] or chr(13) [LF]. Quote .nerd
aewarnick Posted March 11, 2003 Author Posted March 11, 2003 (edited) It apparently is not there at all but the space is there!! When I use this I get the error index outside bounds. if((int)e.KeyCode==(int)Keys.Enter) { string n= this.RTB.Text; this.RTB.Text=""; MessageBox.Show(""+(int)n[0]); and there apparently isn't any linefeed at all when I press enter because it does not even enter the if block: if((int)e.KeyCode==(int)Keys.LineFeed) I could not figure out how to grabbing the Enter-Key and setting e.handled = true Can you help me with how to do that? Edited March 11, 2003 by aewarnick Quote C#
Heiko Posted March 12, 2003 Posted March 12, 2003 Somehow I am still stabbing in the dark, because I don't know exactly what you want to achieve. Besides, I am writing all this "ex cathedra", since I haven't tried it myself. a) n[0] --> Assuming that C# Arrays start at the index 0, then this clearly shows that your Text is empty indeed. b) Linefeed is a character, not a key on the keyboard. What about if (e.KeyCode == Keys.Enter) { e.Handled = True exit sub (insert c# syntax to leave the subroutine) } HTH Heiko Quote .nerd
aewarnick Posted March 17, 2003 Author Posted March 17, 2003 That works. It completely stops enter from being manifested at all. Thank you very much. One thing I don't understand is why Handled=true stops enter from being recognized. Why isn't it Handled=false? Quote C#
Heiko Posted March 17, 2003 Posted March 17, 2003 (edited) I understand "Handled" means "AssumeThatThisEventIsAlreadyHandled". Edited March 17, 2003 by Heiko Quote .nerd
aewarnick Posted March 17, 2003 Author Posted March 17, 2003 Sounds right and logical to me. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.