0
我從業務對象的列表,使用下面的代碼填充一個組合框:組合框不填充正確
Dim manufacturers As IList(Of ElectronicsManufacturer) = _electronicLogic.GetManufacturers(category.CategoryID)
If (manufacturers.Count > 0) Then
Me.cbxManufacturer.Enabled = True
Me.cbxManufacturer.Items.Add("(Please Select...)")
Me.cbxManufacturer.Items.Add(manufacturers.ToArray())
我的問題是,組合框不顯示字符串,而是對業務對象的名稱。
我有一個覆蓋在業務對象設置爲我通常做:
public class ElectronicsManufacturer
{
public ElectronicsManufacturer()
{
ManufacturerID = -1;
ManufacturerName = string.Empty;
RequireSerialNumber = false;
}
public int ManufacturerID { get; set; }
public string ManufacturerName { get; set; }
public bool RequireSerialNumber { get; set; }
public override string ToString()
{
return ManufacturerName.ToString();
}
}
但組合框只是顯示ElectronicsManufacturer []數組
我可以在填充組合框的點確認manufacturers
包含52個項目。