|
-
Oct 13th, 2011, 08:02 AM
#1
Thread Starter
Member
[RESOLVED] [Help] TreeView_KeyPress? No detection of Delete Key?
Im trying to use the Delete key to set off the treeview_keypress sub however it appears to do absolutly nothing when I hit any key thats not a letter.
Is there a quick fix for this?
EDIT:I resolved this Simply by changing from keypress to keyup. However Im not sure How to remove the selected node? Il google However helps appreciated Thanks
Ahh well this was a pointless post Im going to repost a new question :| I figured all the treeview stuff out in about 20 mins lol except for one thing.
Last edited by jasonmbrown; Oct 13th, 2011 at 08:21 AM.
-
Oct 13th, 2011, 08:38 AM
#2
Re: [RESOLVED] [Help] TreeView_KeyPress? No detection of Delete Key?
It's always a good idea to post your solution - rememebr that this is public forum and many people come here to get their aswers.
Anyway, if anyone's wondering how node can be removed here is a quick example:
Code:
Option Explicit
Private Sub Form_Load()
With TreeView1
.Style = tvwTreelinesPlusMinusPictureText
.Nodes.Add , , "R", "Root"
.Nodes.Add "R", tvwChild, , "Child1"
.Nodes.Add "R", tvwChild, , "Child2"
.Nodes.Add "R", tvwChild, , "Child3"
.Nodes.Add "R", tvwChild, , "Child4"
.Nodes.Add "R", tvwChild, , "Child5"
.Nodes("R").Expanded = True
End With
End Sub
Private Sub TreeView1_KeyUp(KeyCode As Integer, Shift As Integer)
If Shift = 0 Then
Select Case KeyCode
Case vbKeyDelete
If Not TreeView1.SelectedItem.Key = "R" Then 'keep the root node
TreeView1.Nodes.Remove TreeView1.SelectedItem.Index
End If
End Select
End If
End Sub
-
Oct 14th, 2011, 06:20 PM
#3
PowerPoster
Re: [RESOLVED] [Help] TreeView_KeyPress? No detection of Delete Key?
-- "vbKeyDelete" := Is what, I think that what your after??? Also have .KeyPreview = True, in the properties for the Form, and even if it appears in the Control, have that too selected, as well. I cannot remember if that appears in a TreeView in VB6. Also try a Context Menu, that is attached to the TreeView, that would have better results to the Control's process of things??? But that would only be a suggestion, and then not follow me if you don't want to...
About your Delete key not working: := Try using the Shift process inaddition to the KeyCode process. Maybe that it would work be using that process, and then see what happens. If so then trap that to not execute...
Last edited by ThEiMp; Oct 14th, 2011 at 06:26 PM.
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
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
|