Groups | Blog | Home
all groups > vb.net > january 2004 >

vb.net : property: can it be an object?



David Browne
1/5/2004 4:59:02 PM

[quoted text, click to view]

Your propery definition is messed up.
Should be:

Public Property lvwTD() As ListView
Get
return m_lvwTD
End Get
Set(ByVal Value As ListView)
m_lvwTD = Value
End Set
End Property

Don't use the name of the property as a local variable. It's a bad habit
from VB6, and leads to errors and confusion like you just experienced.

David


tmaster
1/5/2004 10:56:59 PM
Can I pass a listview to another form using a property definition like this?

Public Class frmToDoDetail
Inherits System.Windows.Forms.Form

Private m_lvwTD As ListView

Public Property lvwTD() As ListView
Get
lvwTD = m_lvwTD
End Get
Set(ByVal Value As ListView)
m_lvwTD = lvwTD
End Set
End Property

.... try to access the listview using m_lvwTD or lvwTD doesn't work?
------------------------------

Here's my attempt at the 'calling' side of the code:

Dim frmTemp As New frmToDoDetail()

frmTemp.lvwTD = lvwToDo
If frmTemp.edit Then...

I do not get any syntax errors, yet the 'passed' listview object is
'nothing'. Am I on the right track?
Thanks.

tmaster
1/5/2004 11:22:01 PM
Thanks. Your suggestion worked fine.

"David Browne" <davidbaxterbrowne no potted meat@hotmail.com> wrote in
message news:OCKAE%2390DHA.1684@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

hirf-spam-me-here NO[at]SPAM gmx.at
1/6/2004 12:40:07 AM
* "tmaster" <leefields@travelmasterusa.com> scripsit:
[quoted text, click to view]

Replace the line above with 'Return m_lvwTD'.

[quoted text, click to view]

--
Herfried K. Wagner [MVP]
AddThis Social Bookmark Button