473,466 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

accessing a control that's on another form using property

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.


Nov 20 '05 #1
1 1822
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.



Nov 20 '05 #2

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

Similar topics

3
by: Tom Meuzelaar | last post by:
Hello: I'm using VB6 in VS enterprise. I'd like to place an HTML form inside a VB container, have a user fill out the form information, click a submit button, and then have the program capture...
1
by: J F | last post by:
Hi all I'm totally new to Visual Studio, coming from Delphi. My question, I'm sure is pretty trivial. I'm using C# I have a component class (Project/Add Class/Component Class). In this...
3
by: Vivek Sharma | last post by:
Hi, I have created a dropdownlist as a web user control. I am using its multiple instances on the webpage. How do I access the selectedValue of each instance? All the instances have different...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
0
by: Geraldine Hobley | last post by:
Hello I have a problem whereby I have a treeview control on one form called projecttree and I wish to clea the nodes from this control in another form The form that contains the treeview is...
5
by: RSH | last post by:
I havent been able to set a property from another class with out getting some sort of error. Can someone please tell me what I'm doing wrong here? Public Class Form1
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
0
by: ansh20 | last post by:
I am adding run time generate controls in array. Now I want to retrieve those controls in other subroutine in same form. But when I am tring to retrieve control it says "Object variable or with...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.