Reputation: 1746
I have a BindingList
that I am displaying in a DataGridView
my issue is that the one of the properties that I am displaying is a byte[]
which I think that it is interpreting it as a bitmap (from the error message).
There are two solutions that I can see
What I want is to display it as a string so some sort of explicit cast?
I could make a new column that holds the password converted to a string. This seems a bit kludgy and I would prefer to not do it.
Upvotes: 0
Views: 137
Reputation: 205769
Once you have control on the underlying data source class, you can add a special property used just for data binding (this way not breaking the existing code) and use attributes to control which one applies to UI.
Let assume your class is something like this
class MyClass
{
// ....
public byte[] Password { get; set; }
}
You can change it as follows
class MyClass
{
// ....
[Browsable(false)]
public byte[] Password { get; set; }
[DisplayName("Password")]
public string PasswordText
{
get { ... }
}
}
and will get the desired behavior in DataGridView
and similar controls.
Upvotes: 1