Problem binding arraylist to combobox
-
private struct modelStruct
{
public string theModel;
public int theModelID;
}
private modelStruct thisModelStruct;
private ArrayList availableModels = new ArrayList();I add some items to the arraylist. Then I want
cboModel.DataSource = availableModels;
cboModel.DisplayMember = "ModelID";
cboModel.ValueMember = "theModelID";But I need to do some casting or content exctraction, but where and how? For DisplayMember the combobox shows "ToolHistory.History+modelStruct". I have tried
cboModel.DisplayMember = thisModelStruct.theModel;
but it makes no difference. -
private struct modelStruct
{
public string theModel;
public int theModelID;
}
private modelStruct thisModelStruct;
private ArrayList availableModels = new ArrayList();I add some items to the arraylist. Then I want
cboModel.DataSource = availableModels;
cboModel.DisplayMember = "ModelID";
cboModel.ValueMember = "theModelID";But I need to do some casting or content exctraction, but where and how? For DisplayMember the combobox shows "ToolHistory.History+modelStruct". I have tried
cboModel.DisplayMember = thisModelStruct.theModel;
but it makes no difference.AFAIK your data provider must have properties, not fields, of the specified name(s) for data binding to work. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]