Hi again
I am still working on the issues I described in my thread http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=8169.
Basically, I want a combobox that is loaded with an Entity COllection, PLUS an additional item "<All>". I wont post all the code unless anybody wants it but basically to do this:
1. I created a custom class to represent each item that will appear in the COmboBox:
private class ObjectOptionalComboBoxItem
{
private IbObjectEntity ibObjectEntity;
public IbObjectEntity IbObjectEntity
{
get { return ibObjectEntity; }
set { ibObjectEntity = value; }
}
// This is the ValueMember of the combo
private int returnValue;
public int ReturnValue
{
get { return returnValue; }
set { returnValue = value; }
}
// This is the DisplayMember of the combo
private String displayText;
public String DisplayText
{
get { return displayText;}
set { displayText = value;}
}
};
2.At runtime I create a List<> of these, and the first item in the list is the "<All>" entry
ObjectOptionalComboBoxItem item;
List<ObjectOptionalComboBoxItem> itemList = new List<ObjectOptionalComboBoxItem>();
// Add the "<All>" entry first
item = new ObjectOptionalComboBoxItem();
item.IbObjectEntity = null;
item.ReturnValue = -1;
item.DisplayText = kAllEntryText;
itemList.Add(item);
- Remainder of the list is populated by fetching an Entity List and iterating through it, adding the objects to my custom List<>
IbObjectCollection ibObjectList;
ObjectDataCacheManager cacheManager = ObjectDataCacheManager.GetInstance;
ibObjectList = cacheManager.FindChildrenOf(ParentObID);
foreach (IbObjectEntity ibObjectEntity in ibObjectList)
{
item = new ObjectOptionalComboBoxItem();
item.IbObjectEntity = ibObjectEntity;
item.DisplayText = ibObjectEntity.ObName;
item.ReturnValue = ibObjectEntity.ObId;
itemList.Add(item);
}
- I set the list's DataSource to my custom list, and the DisplayMember and ValueMember properties to the relevant properties of my custom list item class:
this.DataSource = itemList;
this.ValueMember = "ReturnValue";
this.DisplayMember = "DisplayText";
- Finally, I bind this combobox object to a member in an Entity row I have fetched from the DB ie. to a "database column".
this.ocbComponent.DataBindings.Add(new Binding("SelectedValue", IbBugRow, "BuComponent"));
What I am now seeing is that the combobox appears to bind OK, as the entry that is initially selected in the list when it appears matches the DB value.
HOWEVER, I cannot seem to change the value: I can pick another entry from the list but as soon as I navigate out of the combobox, the selected item reverts to the original value.
Has anybody seen this before and/or got any idea where I am going wrong?? The specific DB column (SQL Server 2000) is a nullable int, in case it helps, although I have been testing with non-null values and it still doesn't work. I am using LLGLGenPro 2.0.0.0 DEMO version, SelfServicing, .NET 2.0, Windows Forms.
Thanks heaps in advance
Cheers
Brett