Menu

#146 DisplayName Attribute modified when columns autogenerated

C#_v2.8.1
wont-fix
None
1
2015-05-11
2015-04-29
No

Hi !

When the listview automatically create colums with GenerateColumns in Utilities/Generator.cs, and when we have property descriptors spécified in our class, this function is called (line 295) to make each column :

public virtual OLVColumn MakeColumnFromPropertyDescriptor(PropertyDescriptor pd) {
OLVColumnAttribute attr = pd.Attributes[typeof(OLVColumnAttribute)] as OLVColumnAttribute;
return MakeColumn(pd.Name, DisplayNameToColumnTitle(pd.DisplayName), !pd.IsReadOnly, pd.PropertyType, attr);
}

I have the following bug with this :
--> my proprety descriptor "DisplayName" is : "Epaisseur (µm)" in my class.

But when the function DisplayNameToColumnTitle is called to create column, it change the Name with "Epaisseur (Mm)", same exemple with "Grammage (g/m²)" become "Grammage (G/M²)".
I think it's because of the regex in the function DisplayNameToColumnTitle.

When we create a column from propertydescrtiptor, I think you can remove the call of the function DisplayNameToColumnTitle because we already have set the good text to appear in the column title.

Discussion

  • Phillip Piper

    Phillip Piper - 2015-05-11

    In general, the DisplayName of a property is simply the name of the property, e.g. SomethingLikeThisProperty. To have those pretty names, you must have put a DisplayName() attribute on the property itself.

    To have those exact string as your column title, put an OLVColumn() attribute on your property instead, and set the Title to be the pretty string you want.

     
  • Phillip Piper

    Phillip Piper - 2015-05-11

    Closed, since this is not a bug.

     
  • Phillip Piper

    Phillip Piper - 2015-05-11
    • status: open --> wont-fix
     

Log in to post a comment.