Solved

obtaining an object from a listBox bound to an ArrayList

Posted on 2003-11-25
1
205 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# GridRow get Old/New Value 1 55
Iterate a dictionnary to change values 4 53
C# TextBox 11 30
Authentication of Web Services 3 49
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

17 Experts available now in Live!

Get 1:1 Help Now