I used this thread's answer to bind a DataGridView to a dictionary:
DataGridView bound to a dictionary
This works fine if I use Dictionary<string, double>
, but 开发者_开发百科if I use a class instead of string (Dictionary<MyClass, double>
) the DataGridView displays the string representation of MyClass. MyClass has a string property (Value) that I would like to be displayed in the DataGridViwe column. Is there a way to accomplish this?
The simplest method would be to implement ToString()
in your class, if this is an option, eg:
public class MyClass
{
public string Value { get; set; }
public override string ToString()
{
return Value;
}
// ...
}
精彩评论