Binding an arraylist to a datagridview... other options?

elorc
elorc used Ask the Experts™
on
I have a class with three public properties: ItemID, ItemName, ItemLocation. What I want to do is put this into an arraylist and bind it to a DataGridView (or some other control that displays this as a table if the DataGridView doesn't allow it). I do something similar with the combo box. For example, I have a combobox that is supposed to hold employee ID and names. I want only the name to display, but when the user submits the form I want it to use the employee ID instead. So I just do something like this:


EmployeeArrayList.Add(New EmployeeInfo("Bob", "105"))
...
EmployeeArrayList.Add(New EmployeeInfo("Joe", "120"))

ComboBox1.ValueMember = "EmployeeID"
ComboBox1.DisplayMember = "EmployeeName"
ComboBox1.DataSource = EmployeeArrayList


That works perfect. I'm just trying to determine if I can do something similar with the DataGridView. If not, is there another control that I can use to do this? Or is my only option to do something a little more "manual" like going through the arraylist with a For/Next and inserting each item row by row?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014
Commented:
I would be much easier to use a DataTable. I can provide the code if you are interested in taking that route.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial