Table of Contents

Items

Adding items

Items live inside a column's Items collection:

var
  item: TTMSFNCKanbanBoardItem;
begin
  item := KanbanBoard1.Columns[0].AddItem('Fix login bug');
  item.Title := 'AUTH-42';
  item.Color := gcLightYellow;
end;

AddItem accepts an optional text argument. The returned object can be configured further before the board refreshes.

Item properties

Property Description
Title Short label shown above the body text
Text Body / description text (HTML if it starts with <)
Color Background color when UseDefaultAppearance is False
TitleColor Title background color when UseDefaultAppearance is False
TextColor Body text color when UseDefaultAppearance is False
TitleFontColor Title text color when UseDefaultAppearance is False
SelectedTextColor Body text color in selected state
SelectedTitleColor Title color in selected state
DisabledTextColor Body text color in disabled state
DisabledTitleColor Title color in disabled state
Enabled When False, item is drawn in a disabled style
Visible Show or hide the item
UseDefaultAppearance When False, per-item colors override ItemsAppearance
Height Item height; -1 uses auto-sizing
HorizontalTextAlign Horizontal alignment of body text
VerticalTextAlign Vertical alignment of body text
Trimming Text trimming for body text
WordWrapping Word-wrap for body text
TitleHorizontalTextAlign Horizontal alignment of title
TitleVerticalTextAlign Vertical alignment of title
TitleTrimming Text trimming for title
TitleWordWrapping Word-wrap for title

Expand and collapse

Individual items can be expandable, allowing the user to show or hide extra detail:

item.Expandable := True;
item.Expanded := False;   // start collapsed

Mark areas

Mark areas are colored stripes on item edges, useful for status or priority indicators:

item.MarkType := mtLeft;             // show mark on left edge only
item.MarkColor := gcOrangeRed;       // default color for all edges
item.MarkColorLeft := gcOrangeRed;   // left edge color specifically
item.MarkSizeLeft := 6;              // width of left stripe in pixels

MarkType flags can be combined using set syntax to show marks on multiple edges:

item.MarkType := [mtTop, mtBottom];
item.MarkColorTop := gcGreen;
item.MarkColorBottom := gcRed;

Bitmap

Attach an image to the left side of an item:

// Load from file
item.Bitmap.LoadFromFile('avatar.png');

// Or reference a BitmapContainer by name
item.BitmapName := 'avatar';

HTML template

For rich formatting, set an HTMLTemplate on ItemsAppearance and supply values per item via HTMLTemplateItems:

// Board-level template (set once)
KanbanBoard1.ItemsAppearance.HTMLTemplate :=
  '<b>[TITLE]</b><br/><font color="gray">[ASSIGNEE]</font>';

// Per-item substitution values
item.HTMLTemplateItems.AddPair('TITLE', item.Title);
item.HTMLTemplateItems.AddPair('ASSIGNEE', 'Alice');

Moving and copying items

// Move item to column index 2 at the end
item.MoveItem(KanbanBoard1.Columns[2]);

// Copy item to column index 1 at position 0
item.CopyItem(KanbanBoard1.Columns[1], 0);

Column-level equivalents accept a source item:

KanbanBoard1.Columns[0].CopyItem(item, KanbanBoard1.Columns[2]);

Selecting items

// Select a single item
KanbanBoard1.Columns[0].SelectItem(0);

// Select multiple items (requires MultiSelect = True)
KanbanBoard1.Columns[0].SelectItems([0, 2, 4]);

// Check whether an item is selected
if item.IsSelected then ...;

// Get all selected items in a column
var arr := KanbanBoard1.Columns[0].GetSelectedItems;

Persistence

// Save an item to a string
var s := item.SaveToString;

// Restore from the saved string
item.LoadFromString(s);

SaveToString accepts an optional ATextOnly: Boolean flag (default True) — set it to False to also serialise appearance overrides such as colors and mark settings.

Finding items and columns

When you have a database-backed adapter, look up an item by its primary key:

var item := KanbanBoard1.FindItemWithDBKey('TASK-1042');
if Assigned(item) then
  KanbanBoard1.Columns[0].SelectItem(item.Index);

FindItemWithDBKey scans every column for the first item whose DBKey matches and returns nil if none is found.

Hit-test board coordinates to discover which column the user clicked:

procedure TForm1.KanbanBoard1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Single);
var
  col: TTMSFNCKanbanBoardColumn;
begin
  col := KanbanBoard1.XYToColumn(X, Y);
  if Assigned(col) then
    StatusBar1.SimpleText := 'In column: ' + col.Header.Text;
end;

For item-level hit-testing inside a single column, see Item lookup and bulk selection.

Combined example — colored marks, bitmap, and HTML template

KanbanBoard1.BeginUpdate;
try
  KanbanBoard1.ItemsAppearance.HTMLTemplate :=
    '<b>[TITLE]</b><br/><font size="10" color="gray">[DESC]</font>';

  var col := KanbanBoard1.Columns[0];
  var it := col.AddItem;
  it.HTMLTemplateItems.AddPair('TITLE', 'Deploy to staging');
  it.HTMLTemplateItems.AddPair('DESC', 'Run smoke tests after deploy');
  it.MarkType := [mtLeft];
  it.MarkColorLeft := gcDodgerBlue;
  it.MarkSizeLeft := 5;
  it.BitmapName := 'deploy-icon';
finally
  KanbanBoard1.EndUpdate;
end;
  • TTMSFNCKanbanBoardColumns, ItemsAppearance, SelectedItem, SelectItem, FindItemWithDBKey, XYToColumn
  • TTMSFNCKanbanBoardItemMoveItem, CopyItem, SaveToString, LoadFromString, IsSelected, SelectItem

See also