473,327 Members | 1,979 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,327 software developers and data experts.

Accessing a Listbox from another Class?

I have a windows form listbox in one class and I need to reference it
in another class, eg. I need to add an item to the listbox. What is
the correct way to setup the listbox and then set a pointer to pass to
my sub-class. I tried to define a listbox in my new class and then
code:

class.listbox = this.listbox;

The compiled said OK but I had an exception when I attempted to access
the
listbox from the sub_class.

Note. This is not a internal class but a new class under the main
namespace.

Thanks
P.S. Can this even be done. No one at my company has tried this
Nov 13 '05 #1
1 6295
David, you need to pass an instance of your form class to your second class.
Once you have that instance you will have access to the listbox.

--
Greg Ewing [MVP]
http://www.claritycon.com/
"David" <db*******@comcast.net> wrote in message
news:8q********************************@4ax.com...
I have a windows form listbox in one class and I need to reference it
in another class, eg. I need to add an item to the listbox. What is
the correct way to setup the listbox and then set a pointer to pass to
my sub-class. I tried to define a listbox in my new class and then
code:

class.listbox = this.listbox;

The compiled said OK but I had an exception when I attempted to access
the
listbox from the sub_class.

Note. This is not a internal class but a new class under the main
namespace.

Thanks
P.S. Can this even be done. No one at my company has tried this

Nov 13 '05 #2

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

Similar topics

2
by: Luna | last post by:
Hi, I want to pass the values that have been chosen from a few comboboxes into a listbox as a single entry. how do i do this?? this is what i tried... it will probably give u some...
4
by: f_salazar | last post by:
English Version !! Hi !! I have a page with a Form, inside the form I have listbox with 'X' elements. Wend I submit the page, an ASP process inside the page have to read those elements and...
3
by: SamIAm | last post by:
Hi I have a form named form1. I have a class called class1. I want to call a recursive method in class1 called MyMethod() I would like log info to a listbox, listbox1, on the form as MyMethod...
8
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
1
by: undercups | last post by:
his is a hybrid problem i.e. the answer lies either in javascript or vb.net so forgive me if this is the wrong group. I have this javascript: function moveItems(fromItem, toItem) // Moves...
0
by: Dave | last post by:
Hi all, I have a listbox that is complex bound by an arraylist. The problem is that when I delete an object from the arraylist, the listbox does not reflect those changes. I tried refreshing...
5
by: MrJim | last post by:
How should variables be declared and referenced in both the base and derived form so they can be accessed?
5
by: lukasmazur | last post by:
Hi I have a problem with using listBox1. I have a two forms form1 and form2. In form1 are controls listBox1, textBox1 and button witch creating object of class Form2. In class Form2 I create a...
4
by: nottarealaddress | last post by:
I'm trying to get my feet wet in VB2005 (our new standard at work after officially stopping new development in VB6 about a month ago). I'm working with a simple sql 2005 table of 50 entries, one...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.