473,382 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Event not work with new class that Inherits TreeNode



I define my class as below, I don't need to override the "new(text as
string)" method as it not inherited, but I don't know why.

-------------------

Public Class TreeNode2

Inherits System.Windows.Forms.TreeNode

Private m_UID As Integer

ReadOnly Property HoldData()

Get

Return m_UID

End Get

End Property

Sub New(ByVal txt As String, ByVal UID As Integer)

MyBase.New(txt)

m_UID = UID

End Sub

End Class

-------------------

I create an instance of the new class in the code below

--------------------

Dim parentnode As TreeNode2

parentnode = New TreeNode2("1st Tree Node ", -1)

----------------

I then respond to the event of the treeview, it is at this point I have a
problem as VB.Net says UID is not a member of TreeNode2

-----------------

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

Dim mynode As TreeNode2

mynode = CType(e.Node, TreeNode2)

MessageBox.Show(mynode.UID)

End Sub
Nov 20 '05 #1
2 1457

"Brian" <n@a.com> wrote in message
news:ab******************************@news.teranew s.com...


I define my class as below, I don't need to override the "new(text as
string)" method as it not inherited, but I don't know why.

-------------------

Public Class TreeNode2

Inherits System.Windows.Forms.TreeNode

Private m_UID As Integer

ReadOnly Property HoldData()

Get

Return m_UID

End Get

End Property

Sub New(ByVal txt As String, ByVal UID As Integer)

MyBase.New(txt)

m_UID = UID

End Sub

End Class

-------------------

I create an instance of the new class in the code below

--------------------

Dim parentnode As TreeNode2

parentnode = New TreeNode2("1st Tree Node ", -1)

----------------

I then respond to the event of the treeview, it is at this point I have a
problem as VB.Net says UID is not a member of TreeNode2

-----------------

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

Dim mynode As TreeNode2

mynode = CType(e.Node, TreeNode2)

MessageBox.Show(mynode.UID)

End Sub

Nov 20 '05 #2
Hi,

You never added a UID property. The read only property HoldData
returns the UID.

Ken
---------------

"Brian" <n@a.com> wrote in message
news:ab******************************@news.teranew s.com:
I define my class as below, I don't need to override the "new(text as
string)" method as it not inherited, but I don't know why.

-------------------

Public Class TreeNode2

Inherits System.Windows.Forms.TreeNode

Private m_UID As Integer

ReadOnly Property HoldData()

Get

Return m_UID

End Get

End Property

Sub New(ByVal txt As String, ByVal UID As Integer)

MyBase.New(txt)

m_UID = UID

End Sub

End Class

-------------------

I create an instance of the new class in the code below

--------------------

Dim parentnode As TreeNode2

parentnode = New TreeNode2("1st Tree Node ", -1)

----------------

I then respond to the event of the treeview, it is at this point I have a

problem as VB.Net says UID is not a member of TreeNode2

-----------------

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e
As
System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

Dim mynode As TreeNode2

mynode = CType(e.Node, TreeNode2)

MessageBox.Show(mynode.UID)

End Sub


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 262.10.6 - Release Date: 5/28/2004
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andy Read | last post by:
Hello all, I have the requirement to produce source code that produces an object hierarchy. Example: Root | Folder 1
3
by: IMS.Rushikesh | last post by:
Hi All, There is a scenario, in which there is a counter in my base class. There is some initial value of this counter (check below code). Now there is a function "DecreaseCount", which will...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
4
by: Tom | last post by:
Hello everyone, I found a frustrating behavior in the TreeView control in .NET 2.0. The TreeNode that is passed in the TreeNodeMouseClickEventArgs is incorrect when the TreeView automatically...
8
by: Jerry | last post by:
Hi, My app is controled by a treeview. Each node brings a subform for input and calculations to the front. The subforms are loaded as controls on the main form. Dim ctl As Control For Each...
2
by: techsatish | last post by:
Hi, I want the double click event to call(here not able to get the MouseEventArgs) and execute the mouseup event code or any one tell me how to make my treecontrol double click nodes to behave...
2
by: RSH | last post by:
Hi, I have been trying to follow a tutorial on raising an event from a user control and then handling it in the parent page. The article is a little vague so I believe I have the code in...
1
by: Jordan S. | last post by:
I'm just wondering if this would work. Please note that I'm not asking *how* to raise events. I'm clear on that. What I'm not clear on is the sequence in which events are raised by custom controls...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.