This question is locked. New answers and comments are not allowed.
Most of the GUIs uses the ToString() method to represent an object on the view.
E.g.
Maybe we can somehow tick in the designer a string field to specify that we want to see that field as essential, and make the ToString() implementation automatically?
Many thanks
E.g.
var context = new EntitiesModel();companyTypeComboBoxEdit.Properties.Items.AddRange(context.ContactTypes);Unfortunately it will show a list of this by default:
DataAccessModel.Contacts.CompanyType
DataAccessModel.Contacts.CompanyType
DataAccessModel.Contacts.CompanyType
DataAccessModel.Contacts.CompanyType
DataAccessModel.Contacts.CompanyType
I will need to do this:
namespace DataAccessModel.Contacts{ public partial class CompanyType { public override string ToString(){ return _companyTypeName; } }} To get the required list:
- Public Limited Company
- Limited Company
- Sole Trader
- Limited Liability Partnership
- Partnership
Of course I can use an essential attribute instead of the overridden method there in that example.
But sometime it would be difficult to specify this, especially in a labyrinth of some GUI libraries. It can simply takes a call to the ToString() without any chance to specify the member.
So I have many files like that.
Or like this:
namespace DataAccessModel.Contacts{ public partial class NewCompany { public override string ToString(){ return _newCompanyName; } }}Maybe we can somehow tick in the designer a string field to specify that we want to see that field as essential, and make the ToString() implementation automatically?
Many thanks