[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

obtaining an object from a listBox bound to an ArrayList

Posted on 2003-11-25
1
Medium Priority
?
215 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 600 total points
ID: 9823317
Just change your code to:

CustomObj o3 = (CustomObj)lb.SelectedItem;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

834 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