Solved

obtaining an object from a listBox bound to an ArrayList

Posted on 2003-11-25
1
204 Views
Last Modified: 2010-04-16
I have an arrayList that I add several custom class objects to
CustomObj{
   private a;
   private b;

   public A{ get a }
   public B{ get b }
}

CustomObj o;
CustomObj 02;

ArrayList a;

a.add(o);
a.add(o2);

I bind a listBox to my ArrayList and the user selects an item from the list

listBox lb;

lb.DataSource = a;
lb.DisplayMember ="A";
lb.ValueMember ="B";

This works up to here.  How do my object out of the ListArray?

I want:
CustomObj o3 = a[lb.SelectedIndex];

a[lb.SelectedIndex] is of type Object.

Any help is appreciated.
0
Comment
Question by:WhatupE
1 Comment
 
LVL 20

Accepted Solution

by:
TheAvenger earned 150 total points
Comment Utility
Just change your code to:

CustomObj o3 = (CustomObj)lb.SelectedItem;
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now