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?