Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9136607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:58:30+00:00 2026-06-17T08:58:30+00:00

Process: A node is added in a treeview control with node text = textbox1.text

  • 0

Process: A node is added in a treeview control with node text = textbox1.text

I want to prevent addition of duplicate node i.e. say, if a node with text “ABC” is added then next time, a node with text “ABC” should not be added to treeview control.

I tried following methods but could not achieve desired result.
Method A)

Dim list As New ArrayList
list.Add(TextBox1.Text) 
if list.Contains(Textbox1.Text) then
       MsgBox("Use different name")
else 
       .....code to add node with text
end if

Method B)

if Treeview1.Nodes.Count > 0 then 
   For i = 0 to Treeview1.Nodes.Count
      if Treeview1.Nodes(i).Text=Textbox1.Text then
         MsgBox("Use different name")
      end if
   next
else 
   ........code to add node with text
end if 

I could not understand the solutions suggested for C# on this forum.

Any help will be really appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:58:31+00:00Added an answer on June 17, 2026 at 8:58 am

    Method A should work OK. You might have another error in your code (in the else section?). list should be declared static if it is in a function that’s being called repeatedly, else it will be reset to new (cleared) each time.

    Method B has a couple of errors: (1) the for statement should be For i = 0 to Treeview1.Nodes.Count - 1 (maybe use “for each”), and the else with the code to add the node should be after the msgbox statement. Also, method B only search for the root node(s) of the treeview. You would need to traverse the tree to check all the nodes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using XSLT 1.0, I want to process four node sets, in order, A, B,
I would like to create a child process in node, and block in a
How can i process a coffeescript code directly into javascript in node.js ? maybe
Tree traversal refers to the process of visiting each node in a tree data
I process a lot of text/data that I exchange between Python, R, and sometimes
How can I add a process instruction to ~50 xml files? <?xml-stylesheet type=text/xsl href=Sample.xsl?>
I have a Node.JS server that works fine on localhost . Now I want
We are developing a Data Synapse calc node process in C# that requires functionality
I write (in-process) hook to prevent add BAD tag name locally: .hg/hgrc : pretag.badtagname
here is the simple code. i just want to know how to process the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.