unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, NxScrollControl, NxSheet;

type
  TForm1 = class(TForm)
    NextSheet1: TNextSheet;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  NxSheetCell;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
{$MESSAGE '(Demo Hint) Unit NxSheetCell need to be added in uses section to use Alignment or LineStyle property.'}

//
//  1. Merge cells from 1, 1 to 3, 2 and set text, color and font
//

  NextSheet1.MergeCells(1, 1, 3, 3, caCenter);

{ After cells are merged, top-left cell inside merged region become only
  active cell. }

  NextSheet1.Cell[1, 1].Text := 'Merged region 1';
  NextSheet1.Cell[1, 1].Color := $00F1E5DB;

  NextSheet1.Cell[1, 1].Font.Name := 'Verdana';
  NextSheet1.Cell[1, 1].Font.Size := 12;

{ Again, since only top-left cell is active in merged region, setting frame around this
  cell will frame whole merged region }

  NextSheet1.FrameCell(1, 1, lsThinLine, $00D58E53);

//
//  2. Merge cells from 4, 2 to 5, 4
//

  NextSheet1.MergeCells(4, 2, 5, 5, caCenterRight);

  NextSheet1.Cell[4, 2].Color := $00B4D5FC;
  NextSheet1.Cell[4, 2].Text := 'Merged region 2';

  NextSheet1.FrameCell(4, 2, lsThinDot, $000A6DE4);

//
//  3. Merge cells from 2, 7 to 5, 8
//
  NextSheet1.MergeCells(2, 7, 5, 8, caCenter);

  NextSheet1.Cell[2, 7].Text := 'Merged region 3';

// Draw double line from cell 2 to 5 in row 8

  for i := 2 to 5 do
  begin
    NextSheet1.Cell[i, 8].BorderBottom.Color := clGreen;
    NextSheet1.Cell[i, 8].BorderBottom.LineStyle := lsDouble;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  NextSheet1.MergeSelection;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  NextSheet1.Cell[0, 0].BorderBottom.Color := clGreen;
  NextSheet1.Cell[0, 0].BorderBottom.LineStyle := lsDot;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  with NextSheet1 do
    SplitCells(Selection.StartCol, Selection.StartRow, Selection.EndCol, Selection.EndRow);
end;

end.
