1 Attachment(s)
[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.
Attachment 91255
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.
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.