Hi tmaster,
It looks like the problem is that the ListView is never created. You may
need something like
Dim m_lvwTD As New ListView
or, you can create the object in your constructor (Sub New)
I hope this helps,
Craig, VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).
--------------------
From: "tmaster" <le*******@travelmasterusa.com>
Newsgroups: microsoft.public.dotnet.languages.vb
Subject: accessing a control that's on another form using property
Lines: 70
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <kb*****************@fe1.columbus.rr.com>
Date: Mon, 05 Jan 2004 16:22:40 GMT
NNTP-Posting-Host: 66.61.68.104
X-Complaints-To: ab***@rr.com
X-Trace: fe1.columbus.rr.com 1073319760 66.61.68.104 (Mon, 05 Jan 2004
11:22:40 EST)NNTP-Posting-Date: Mon, 05 Jan 2004 11:22:40 EST
Organization: Road Runner High Speed Online http://www.rr.com
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!newsfeed00.su
l.t-online.de!t-online.de!newsfeed.icl.net!newsfeed.fjserv.net!new shosting.c
om!nx02.iad01.newshosting.com!news-feed01.roc.ny.frontiernet.net!nntp.fronti
ernet.net!tdsnet-transit!newspeer.tds.net!gail.ripco.com!news-xfer.cox.net!p
eer02.cox.net!cox.net!news-server.columbus.rr.com!fe1.columbus.rr.com.POSTED
!not-for-mailXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:170022
X-Tomcat-NG: microsoft.public.dotnet.languages.vb
Within a class, can I create a property that is a listview? Here's what I
tried, but it doesn't seem to work:
'------------ create property to give the second form access to the first
form's listview:
Public Class frmToDoDetail ' (this is the second form)
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 passed listview:
' I've tried all of these references from frmToDoDetail unsuccessfully:
' The error I get is 'Object reference not set to an instance of an
object'.
lvwTD.refresh
me.lvwTD.refresh
me.m_lvwTD.refresh
'------------ try to pass the listview. This sub is part of a form (the
first form) that has a listview on it called lvwToDo:
Private Sub lvwToDo_ItemActivate(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lvwToDo.SelectedIndexChanged
Dim frmTemp As New frmToDoDetail()
frmTemp.lvwTD = lvwToDo
'After the above statement executes, the debugger says that
lvwToDo={System.Windows.Form.Listview}, but frmTemp.lvwTD=nothing.