473,769 Members | 7,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List box DataSource question

For an owner drawn list box,

I have a collection that represents some graphics objects in my app.
I inherited the collection class from collectionbase.

It would be nice to somehow just set the lstbox.datasour ce=mycollection
and have it work, but this seemed to never work so I just run through my
collection and popualate the list.
This is a real waste because the collection contains classes that have one
property that is a bitmap. There won't be many of them but still this is
duplicating memory.

Anyone know a way to make a collection class that works normally and also
with a listbox?
Remember I owner draw each item.

Thanks,

Shane
Nov 20 '05 #1
3 1706
Hi,

Try setting the displaymember in addition to the datasource. Remember
the displaymember can be any property in the class held in the
collection.

Ken
-----------

"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:eR******** ******@TK2MSFTN GP11.phx.gbl:
For an owner drawn list box,

I have a collection that represents some graphics objects in my app.
I inherited the collection class from collectionbase.

It would be nice to somehow just set the lstbox.datasour ce=mycollection
and have it work, but this seemed to never work so I just run through my

collection and popualate the list.
This is a real waste because the collection contains classes that have one

property that is a bitmap. There won't be many of them but still this is

duplicating memory.

Anyone know a way to make a collection class that works normally and also

with a listbox?
Remember I owner draw each item.

Thanks,

Shane


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
Nov 20 '05 #2
hmm..
The thing is. I have a class lets say
clsGraphicObjec t
and a collection class
colGraphicOjbec t
inherits collectionbase

which has a list of clsGraphicObjec ts

I want to set listbox data source to this colGraphicObjec t's Items,
but also the result is not a string, but in clsGraphicObjec t, there is a
picture property that is a bitmap--that is what I want to display in the
listbox.

Will this still work?

Shane

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

Try setting the displaymember in addition to the datasource. Remember
the displaymember can be any property in the class held in the
collection.

Ken
-----------

"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:eR******** ******@TK2MSFTN GP11.phx.gbl:
For an owner drawn list box,

I have a collection that represents some graphics objects in my app.
I inherited the collection class from collectionbase.

It would be nice to somehow just set the lstbox.datasour ce=mycollection
and have it work, but this seemed to never work so I just run through my

collection and popualate the list.
This is a real waste because the collection contains classes that have one
property that is a bitmap. There won't be many of them but still this is
duplicating memory.

Anyone know a way to make a collection class that works normally and also
with a listbox?
Remember I owner draw each item.

Thanks,

Shane


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004

Nov 20 '05 #3
Hi,

Sure the listbox item is an object not a string.

Ken
---------------

"SStory" <Th*******@TAKE OUTTHISSPAMBUST ERsofthome.net> wrote in message
news:#u******** ******@TK2MSFTN GP11.phx.gbl:
hmm..
The thing is. I have a class lets say
clsGraphicObjec t
and a collection class
colGraphicOjbec t
inherits collectionbase

which has a list of clsGraphicObjec ts

I want to set listbox data source to this colGraphicObjec t's Items,
but also the result is not a string, but in clsGraphicObjec t, there is a

picture property that is a bitmap--that is what I want to display in the

listbox.

Will this still work?

Shane

"Ken Tucker [MVP]" <HYPERLINK
"mailto:vb***@b ellsouth.net"vb ***@bellsouth.n et> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

Try setting the displaymember in addition to the datasource. Remember
the displaymember can be any property in the class held in the
collection.

Ken
-----------

"SStory" <HYPERLINK
"mailto:Th***** **@TAKEOUTTHISS PAMBUSTERsoftho me.net"TheStory s@TAKEOUTTHISSP A
MBUSTERsofthome .net> wrote in message
news:eR******** ******@TK2MSFTN GP11.phx.gbl:

For an owner drawn list box,

I have a collection that represents some graphics objects in my app.
I inherited the collection class from collectionbase.

It would be nice to somehow just set the
lstbox.datasour ce=mycollection
and have it work, but this seemed to never work so I just run through
my

collection and popualate the list.
This is a real waste because the collection contains classes that
have
one

property that is a bitmap. There won't be many of them but still
this
is

duplicating memory.

Anyone know a way to make a collection class that works normally and
also

with a listbox?
Remember I owner draw each item.

Thanks,

Shane

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.3 - Release Date: 6/18/2004
Nov 20 '05 #4

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

Similar topics

3
4726
by: BobforeApples | last post by:
Hi All, I was trying to apply databinding to a custom collection as in the MSDN Magazine article found in the August, 2005 issue. After converting the code in the article to C# and applying it to an existing set of classes, I tried using the collection as the datasource for a standard DataGrid control. The problem is that the collection contains a collection as one of it's member properties (ie. SampleCollection contains a...
5
4231
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
2
1417
by: Water Cooler v2 | last post by:
What am I missing here. I bind a drop-down list in ASP.NET placed on a web form to a DataReader. The binding is done at run-time and not at design time. Here's the code I write to bind the list: Private Sub FillRoles() ddlRole.Items.Clear() ddlRole.DataSource = DataServices.DataProvider.GetReader("select , FROM
11
8556
by: Zorpiedoman | last post by:
The problem is this: I have a list box. I set an array list as the datasource. I remove an item from the array list. I set the listbox datasource to nothing. I set the listbox datasource to the array list again to refresh. Click on an item in the list, and an Indexing error comes up. (in non-user code, it is trying to get an element from the array that is greater than the number of items in the array.) To reproduce:
0
996
by: WebBuilder451 | last post by:
I has a sp used as a datasource bound to a dropdown list. It has a column i need to set another value on change. The value is not the value property of the DDL. how can i get to the value in the datasource? I guess i'm hoping it has a default view associated with it (the datasource). This is, of course a 2.0 question. -- thanks (as always) some day i''m gona pay this forum back for all the help i''m getting
11
76262
by: dave18 | last post by:
Hello all! I found a solution to my original question, but there's still so much I don't understand about it, I thought I'd give this forum a try. At the very least, maybe it will help someone else who got stumped like I did. It seems so simple... binding a DataGridView to a List<T>. These are the two general problems that I kept running into: (1) When the data in the list updated, the data on the screen did not update. (2) When I...
8
12200
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to get a list of SQL Server Instances thru a VB.NET application. I have tried GetDataSource and SMO. I have also tried using ListSQLSvr.exe from http://www.sqldev.net/misc/ListSQLSvr.htm I run all of them on a Windows XP Professional 64bit machine which has 2 instances: mymachine\SQLExpress (Express Edition) and MSSQLSERVER (Developer Edition (64bit)) SQL Browser Service: not running
7
21780
by: Ciri | last post by:
Hi all, I've a problem with a datagridview. The data source of the control is a List<t> where t is type of a class I've created. The class (Person) has some properties like Name, Surname and so on. Now my datagridview is bounded to a collection of Person: dgwPersons=new DataGridView(); dgwPersons.AutoGenerateColumns=false; dgwPersons.Columns.Add("Name","Name"); dgwPersons.Columns.DataPropertyName="Name";...
4
3165
by: sree078 | last post by:
I've a list of items which I bound to multiple combo boxes. In the due course in the code...I had to add an item into one combo box...but I don't want it to be reflected into any other combo boxes...How should I do that... As when I'm trying to add an item...it is being shown in all the combo boxes. private void FillMethod() { BindingSource bs = new BindingSource(); BindingSource bs1 = new BindingSource(); ...
0
9589
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5309
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.