Results 1 to 3 of 3

Thread: [RESOLVED] C# Conversion Help - TextBox/ComboBox as TreeView Node

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2012
    Posts
    2

    [RESOLVED] C# Conversion Help - TextBox/ComboBox as TreeView Node

    I am running Visual Basic 2010 Express edition.

    I have spent a few hours searching for examples and source code on how to turn TreeView nodes into a ComboBox or TextBox. The only real example I found is the C# DropDownTreeView demo from http://www.codeproject.com/Articles/...Dropdown-Nodes . I used http://www.developerfusion.com/tools.../csharp-to-vb/ to convert it and I've managed to fix all the errors but 2. I am getting "raiseevent" errors for 2 lines of code and I can not figure out how to resolve them. The app runs without these 2 lines and the TreeView nodes are all listed properly (with the exception of them being a drop down menu). Does anyone have a working .vb of this demo? or an example of their own on how I can turn a TreeView node into a TextBox/ComboBox?

    The 2 lines with errors are in DropDownTreeView.vb
    Me.m_CurrentNode.ComboBox.SelectedValueChanged += New EventHandler(AddressOf ComboBox_SelectedValueChanged)
    Me.m_CurrentNode.ComboBox.DropDownClosed += New EventHandler(AddressOf ComboBox_DropDownClosed)

    And the errors are 'Public Event SelectedValueChanged (and the other is DropDownClosed)(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

    I apologize if this is an easy thing to figure out but I haven't encountered RaiseEvent statements so I am unsure how to work with them.
    Thank you.

    This is the project converted.
    ExampleDropDown.zip
    Last edited by dirtyrobinson; Sep 11th, 2012 at 01:56 AM. Reason: Issue was resolved

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: C# Conversion Help - TextBox/ComboBox as TreeView Node

    That is how you attach a handler to an even in C#. In VB you either use a Handles clause on the method (which is only valid for fields declared WithEvents) or an AddHandler statement. This C# code:
    Code:
    someObject.SomeEvent += new EventHandler(SomeMethod);
    translates to this VB:
    Code:
    AddHandler someObject.SomeEvent, New EventHandler(AddressOf SomeMethod)
    In both cases you can omit the EventHandler constructor as the delegate type can be inferred from the event.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2012
    Posts
    2

    Re: C# Conversion Help - TextBox/ComboBox as TreeView Node

    Thank you so much jmcilhinney!!

    I'm quite new to Visual Basic and I just could not figure that out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width