Hi
Delano
The grid is looking for a string to display. Where does it look, you ask? It gets the string returned by the object's
ToString() method. In objects like DataTables, DataRows, DataViews, the
ToString() method returns meaningful data but in the case of user defined objects (like your BusinessObject) it returns the-not-so-useful stuffs like namespace membership, blah,blah. The
ToString() method is a member of the
System.Object which is the base of all objects and it is [u]virtual</u> meaning your your BusinessObject class already has it but the problem is, it does not return "sensible" string. The solution is to [u]override</u> the method in your class.
To make myself clear, suppose I have a class Person which I am going to use in a collection to be bound in a comboBox and I want that the combobox should display the "LastName, Firstname MI" format. The following is the code for the class
Code:
public class Person {
string lastName, firstName, MI;
/*
useful members here
*/
public override string ToString() {
return lastName + ", " + firstName + " " + MI;
}
}