Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2007, 06:44 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default TreeView deleting Nodes

Hi,
  I would like to delete nodes from a treeview. the code i'm trying to use is

Code:
Private Sub mnuFDelete_Click()
Dim yeah As String

yeah = tvMain.SelectedItem.Index
tvMain.Nodes.Remove (yeah)
End Sub
This returns an error - Element not found
which highlights the line - tvMain.Nodes.Remove (yeah)

Please explain what i'm doing wrong, and provide a solution.

Thanks,
     Apocolypse


------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped!
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old July 9th, 2007, 01:09 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Apocolypse

The problem is because of the declaration:

You have declared yeah As String

IF you remove this it should work

Regards
Shasur

http://www.dotnetdud.blogspot.com
 
Old July 9th, 2007, 04:01 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

SelectedItem.Index is not a string.

The .Remove method expects a numeric argument when used in the format that you have used.
 
Old July 11th, 2007, 04:16 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

Well removing the yeah doesnt work thats what i tried first!
if the remove method requires a number then how do i get the number of the node i just clicked on?





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to value in b/n nodes Swetha XSLT 1 May 20th, 2008 12:20 PM
TreeView sumith ASP.NET 2.0 Basics 2 October 2nd, 2007 11:42 PM
Help deleting multiple XML nodes sigilaea Visual Basic 2005 Basics 1 October 1st, 2007 04:45 PM
TreeView.Nodes(x).Visible & VB6 BrianWren VB How-To 1 August 28th, 2006 04:03 PM
TreeView surendran Classic ASP Basics 2 October 30th, 2003 06:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.