473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ 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.refres h

me.m_lvwTD.refr esh

'------------ 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_ItemAct ivate(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles lvwToDo.Selecte dIndexChanged

Dim frmTemp As New frmToDoDetail()

frmTemp.lvwTD = lvwToDo

'After the above statement executes, the debugger says that
lvwToDo={System .Windows.Form.L istview}, but frmTemp.lvwTD=n othing.


Nov 20 '05 #1
1 1825
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*******@trav elmasterusa.com >
Newsgroups: microsoft.publi c.dotnet.langua ges.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.colum bus.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.ph x.gbl!cpmsftngx a06.phx.gbl!TK2 MSFTNGP08.phx.g bl!newsfeed00.s u
l.t-online.de!t-online.de!newsf eed.icl.net!new sfeed.fjserv.ne t!newshosting.c
om!nx02.iad01.n ewshosting.com! news-feed01.roc.ny.f rontiernet.net! nntp.fronti
ernet.net!tdsne t-transit!newspee r.tds.net!gail. ripco.com!news-xfer.cox.net!p
eer02.cox.net!c ox.net!news-server.columbus .rr.com!fe1.col umbus.rr.com.PO STED
!not-for-mailXref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:170022
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.refres h

me.m_lvwTD.refr esh

'------------ 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_ItemAct ivate(ByVal sender As System.Object, ByVal e As
System.EventAr gs) Handles lvwToDo.Selecte dIndexChanged

Dim frmTemp As New frmToDoDetail()

frmTemp.lvwTD = lvwToDo

'After the above statement executes, the debugger says that
lvwToDo={Syste m.Windows.Form. Listview}, but frmTemp.lvwTD=n othing.



Nov 20 '05 #2

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

Similar topics

3
15086
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 the field values and write them to an ASCII file on the hard drive. Can anyone confirm that this is even possible? I have dredged up one article...
1
2988
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 component class, I drop an ImageList.
3
2783
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 IDs. Thanks Vivek
6
11270
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" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
2
3608
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
1411
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 called projecttree and the form that I wish to clear the node from the tree, (because I'm connecting to a different database) is called frmConnections ...
5
1939
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
12061
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 likelihood of CRM success from less than 20 percent to 60 percent. WHITEPAPER :
0
1365
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 variable not set". It seems like at the time of adding controls, there is mistake. AnyOne can help me? I am stuck since yesterday. Here is code for what I...
0
7478
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7923
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.