|
-
Apr 25th, 2013, 06:02 PM
#1
Thread Starter
Addicted Member
listbox/textbox
Hello
I've got a textbox and everytime i type then press enter I want what I've just typed to also be placed into a listview on a tab.
Example: if I type in "OP28" then press enter it puts two spaces after that word ready for another one if need be, but I also want it to put that word I just typed into a listview row. I could have numerous words in this text is like "OP28 OP29 OP30" etc and I want it to add individual words into an individual row in a listview.
I thought about a listbox, but it doesn't go with how i want the design to be like and also i want to be able to type in the box without having to have another textbox just to add an item.
Any help would be great, thanks
-
Apr 25th, 2013, 06:23 PM
#2
Re: listbox/textbox
I'm presuming this is a single line text box so surely the logical thing to do would be to clear the textbox on Enter rather than extending the line? Apart from anything else it will save a lot of code tracking the position of the caret and what has just been typed!
Anyway, you need to detect the Enter key using the textbox's KeyDown event. I'm assuming that you know how to add an item to a listview so it's plain sailing once you've done that.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 25th, 2013, 07:45 PM
#3
Thread Starter
Addicted Member
Re: listbox/textbox
oh yes I definitely agree it would be logical, however again the design doesn't really allow it, im not exactly helping myself with this system really aha
Thanks for the reply anyway. I know how to add a row to the listview, how would I track the enter button?
Cheers
-
Apr 25th, 2013, 07:52 PM
#4
Re: listbox/textbox
vb.net Code:
Private Sub TextBox1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
TextBox1.AppendText(" ")
'do other stuff
e.SuppressKeyPress = True 'cancels the beep
End If
End Sub
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 25th, 2013, 08:00 PM
#5
Thread Starter
Addicted Member
Re: listbox/textbox
That's great thanks! I'll test it in the morning, but that will then be able totrack the enter button so it would place what I've just typed into a listview row (when I add the dim etc code) instead of the whole textbox? Cheers
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
|