Solved

obtaining an object from a listBox bound to an ArrayList

Posted on 2003-11-25
1
209 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
ID: 9823317
Just change your code to:

CustomObj o3 = (CustomObj)lb.SelectedItem;
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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