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

Tag Property ComboBox

115 100+
Hi All

I have another Problem. I am trying to retrieve an object from my combo box through the tag property but it's not having any of it. I populate my setOfCars as a collection like so
Expand|Select|Wrap|Line Numbers
  1.  foreach (Car car in DBcars)
  2.                 {
  3.                     car.Tag = car ;
  4.                     SetOfCars.Add(car);
  5.                 }
  6.  
This collection is then returned and used to populate a comboBox

Expand|Select|Wrap|Line Numbers
  1. foreach (Car car in SetOfCars)
  2.             {
  3.  
  4.                 cb_Car.Items.Add(car.Tag);
  5.             }
  6.  
I have a override of ToString() in my class Car.

I then want to grab the selected item in the comboBox as an object. Everything that i have tried is failing miserably. Could anyone suggest how i would go about obtaining the object from the comboBox.
Dec 23 '09 #1
2 8428
truezplaya
115 100+
I have found a solution but i am not sure why the..

Expand|Select|Wrap|Line Numbers
  1. Car.Tag
doesn't do the same thing as i set the items Tag property to the Object
Dec 23 '09 #2
tlhintoq
3,525 Expert 2GB
I'm not sure I follow the reasoning here. Maybe because so little of the total project is here.

You are setting the tag of a car equal to the car itself. I'm not sure why this extra step. I would think if you can add car.Tag which is an object, then you could just add 'car' which is an object.
Expand|Select|Wrap|Line Numbers
  1. foreach (Car car in DBcars)
  2.                 {
  3.                     cb_Car.Items.Add(car);
  4.                 }
I do something just like this for plugins in a listbox. I'm fairly certain that a combox can take an object just like a listbox can.
Dec 23 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Filips Benoit | last post by:
Dear All, W2000 Office2000 Access adp SQLserver DB Problem: Adding a new property for a company in the subform. The FIRST time I Select a property in combobox CPROP_PRP_ID the subform act
3
by: Kent Eilers | last post by:
I want to follow naming conventions for my controls - i usually prefix combo boxes with "cbo". When a form is in datasheet view however i do not want the user to see the 'cbo' prefix in front of...
0
by: Filips Benoit | last post by:
Dear All, W2000 Office2000 Access adp SQLserver DB Problem: Adding a new property for a company in the subform. The FIRST time I Select a property in combobox CPROP_PRP_ID the subform act
2
by: Balamurukan | last post by:
How to retrive property values from our own property window
1
by: geraldine hobley | last post by:
Hello, I wish to set the valuemember of a combobox to the value of a property in a class(projlist - see below). I wish to set the valuember of the combobox cmbstatus to the value of property...
3
by: ScottBH | last post by:
Discovered a fun one that I thought I should share, and hopefully catch Microsoft's attention to update some documentation. I'm a bit new to VB.NET, and was struggling with getting a combo box to...
2
by: JC Voon | last post by:
Hi: My component has a property which type is control, i want it to accept only textbox and combobox, how to tell the properties windows, when drop down or set the property, it only show or...
5
by: Eric A. Johnson | last post by:
Hi Everyone, I am at my wit's end here. I have a combobox (combyQueryTitle) that I need to use in order to select a query for my database project. Therefore, I am using the...
1
by: progressdll | last post by:
I'm trying to change the behaviour of setting the DataSource property of combobox. Here is the behaviour I now see. Setting the DataSource property of combobox to an ArrayList will visual...
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.