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;
}
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.