Solved

obtaining an object from a listBox bound to an ArrayList

Posted on 2003-11-25
1
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 20

Accepted Solution

by:
TheAvenger earned 150 total points
ID: 9823317
Just change your code to:

CustomObj o3 = (CustomObj)lb.SelectedItem;
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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