123456789101112131415161718192021222324252627282930 |
- using System;
- using InABox.Core;
- namespace InABox.DynamicGrid;
- public class DynamicTextColumn : DynamicActionColumn
- {
- public delegate object GetTextDelegate(CoreRow? row);
- public GetTextDelegate Text { get; private set; }
-
- public Alignment Alignment { get; set; }
-
- public string? Format { get; set; }
-
- public DynamicTextColumn(GetTextDelegate text, ActionDelegate? action = null)
- {
- Alignment = Alignment.MiddleCenter;
- Text = text;
- Action = action;
- VerticalHeader = false;
- }
- public override object? Data(CoreRow? row)
- {
- var result = Text?.Invoke(row);
- if (!string.IsNullOrWhiteSpace(Format))
- return String.Format($"{{0:{Format}}}", result);
- return result;
- }
- }
|