Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Hierarchical FormatString

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Hierarchical FormatString
Link Posted: 13-May-2006 07:46
How to set the Hiearhicals column FormatString in databind mode?
Link Posted: 13-May-2006 09:27
You can use a small Hierachycolumn wrapper to implement FormatString functionality:
[C#]
public class FormattedHierarchyColumn : HierachyColumn
{
  public FormattedHierarchyColumn(){}
  public FormattedHierarchyColumn(string name) : base(name){}
  public FormattedHierarchyColumn(string name, string fieldName) : base(name, fieldName){}

  private string formatString = \"G\";//general format

  [DefaultValue(\"G\")]
  public override string FormatString
  {
    get
    {
      return formatString;
    }
    set
    {
      if (formatString != value)
      {
        formatString = value;
        base.OnChanged(InvalidationMode.ColumnWithoutHeader, false);
      }
    }
  }
  
  private string ValueToString(IFormattable value)
  {
    return value != null ? value.ToString(FormatString, NumberFormatInfo.CurrentInfo) : \"Value can't be formatted.\";
  }

  public override string GetTextValue(object value)
  {
    IFormattable fobj = value as IFormattable;
    return fobj != null ? ValueToString(fobj) : base.GetTextValue(value);
  }
}