unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, NxScrollControl, NxSheet, StdCtrls, NxEdit, NxSheetCell, XPMan,
  Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    NextSheet1: TNextSheet;
    Button1: TButton;
    NxComboBox1: TNxComboBox;
    Label1: TLabel;
    Label2: TLabel;
    NxSpinEdit1: TNxSpinEdit;
    Label3: TLabel;
    NxSpinEdit2: TNxSpinEdit;
    Button2: TButton;
    Button3: TButton;
    NxEdit1: TNxEdit;
    Button4: TButton;
    XPManifest1: TXPManifest;
    Button5: TButton;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    Bevel1: TBevel;
    Bevel2: TBevel;
    Bevel3: TBevel;
    procedure NxComboBox1Change(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure NextSheet1SelectCell(Sender: TObject; ACol, ARow: Integer);
    procedure Button1Click(Sender: TObject);
    procedure NxSpinEdit2Change(Sender: TObject);
    procedure NxSpinEdit1Change(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  NxSpinEdit1.AsInteger := NextSheet1.RowCount;
  NxSpinEdit2.AsInteger := NextSheet1.ColCount;
end;

procedure TForm1.NxComboBox1Change(Sender: TObject);
begin
  if NxComboBox1.Text <> '' then NextSheet1.Zoom := NxComboBox1.AsInteger;
end;

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

procedure TForm1.NextSheet1SelectCell(Sender: TObject; ACol,
  ARow: Integer);
begin
  with NextSheet1.Selection do
    Caption := 'Selection: ' + IntToStr(StartCol) + ', ' + IntToStr(StartRow) + ', ' +
      IntToStr(EndCol) + ', ' + IntToStr(EndRow);
  NxEdit1.Text := NextSheet1.Cell[NextSheet1.SelectedCol, NextSheet1.SelectedRow].Text;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i, j: Integer;
begin
  if Form2.ShowModal = mrOk then
  begin
    with NextSheet1.Selection do
    begin
      for j := StartRow to EndRow do
        for i := StartCol to EndCol do
        begin
          if j = StartRow then
          begin
            NextSheet1.Cell[i, j].BorderTop.Assign(Form2.NxBorderPicker1.BorderTop);
          end;
          if j = EndRow then
          begin
            NextSheet1.Cell[i, j].BorderBottom.Assign(Form2.NxBorderPicker1.BorderBottom);
          end;
          if i = StartCol then
          begin
            NextSheet1.Cell[i, j].BorderLeft.Assign(Form2.NxBorderPicker1.BorderLeft);
          end;
          if i = EndCol then
          begin
            NextSheet1.Cell[i, j].BorderRight.Assign(Form2.NxBorderPicker1.BorderRight);
          end;
        end;
    end;
  end;
end;

procedure TForm1.NxSpinEdit2Change(Sender: TObject);
begin
  NextSheet1.ColCount := TNxSpinEdit(Sender).AsInteger;
end;

procedure TForm1.NxSpinEdit1Change(Sender: TObject);
begin
  NextSheet1.RowCount := TNxSpinEdit(Sender).AsInteger;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  i, j: Integer;
begin
  with NextSheet1.Selection do
  begin
    for j := StartRow to EndRow do
      for i := StartCol to EndCol do
      begin
        NextSheet1.Cell[i, j].BorderTop.LineStyle := lsThinLine;
        NextSheet1.Cell[i, j].BorderTop.Color := clRed;
      end;
  end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  NextSheet1.Cell[NextSheet1.SelectedCol, NextSheet1.SelectedRow].Text := NxEdit1.Text;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  with NextSheet1.Cell[2, 2].BorderBottom do
  begin
    Color := clRed;
    LineStyle := lsThinLine;
  end;
  with NextSheet1.Cell[2, 2].BorderRight do
  begin
    Color := clRed;
    LineStyle := lsThinLine;
  end;
  with NextSheet1.Cell[2, 2].BorderLeft do
  begin
    Color := clRed;
    LineStyle := lsThinLine;
  end;
  with NextSheet1.Cell[2, 2].BorderTop do
  begin                    
    Color := clRed;
    LineStyle := lsDouble;
  end;
end;

end.
