unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, NxGridView6, NxColumns6, NxControls6, NxCustomGrid6,
  NxVirtualGrid6, NxGrid6;

type
  TForm1 = class(TForm)
    NextGrid61: TNextGrid6;
    NxReportGridView61: TNxReportGridView6;
    Button1: TButton;
    Edit1: TEdit;
    NxTextColumn61: TNxTextColumn6;
    NxTextColumn62: TNxTextColumn6;
    RadioButton1: TRadioButton;
    GroupBox1: TGroupBox;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    GroupBox2: TGroupBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure RadioButton3Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  { Required for Options parameter }
  NxTypes6;

var
  Options: TNxSearchOptions = [];
  MatchingOptions: TNxSearchMatchingOptions = moContain;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  StartIndex, FoundIndex: Integer;
begin
  StartIndex := NextGrid61.SelectedRow;

  { SelectedRow can be -1 if nothing is
    selected }
  if not NextGrid61.RowExists(StartIndex)
    then StartIndex := 0;

  FoundIndex := NextGrid61.FindText(
    [NxTextColumn61.Index, NxTextColumn62.Index], // -> Column's Indexes
    Edit1.Text, // -> what to find
    StartIndex,
    NextGrid61.RowCount - 1,
    Options, // -> TNxSearchOptions
    MatchingOptions // -> TNxSearchMatchingOptions
  );

  if NextGrid61.RowExists(FoundIndex) then
  begin
    NextGrid61.SelectedRow := FoundIndex;
  end else
  begin
    NextGrid61.SelectedRow := -1;
    Beep;
  end;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  if TCheckBox(Sender).Checked then
    Include(Options, soCaseSensitive)
  else
    Exclude(Options, soCaseSensitive);
end;

procedure TForm1.CheckBox2Click(Sender: TObject);
begin
  if TCheckBox(Sender).Checked then
    Include(Options, soRestartAfterEnd)
  else
    Exclude(Options, soRestartAfterEnd);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  NextGrid61.AddCells(
    [
      'Jim', 'Carey',
      'Garry', 'Simpson',
      'Lisa', 'Jackson',
      'Marie', 'Lopez',
      'George', 'Johnson',
      'Anne', 'Miller',
      'Jimmy', 'Donovan',
      'Larry', 'Carlston',
      'Lucy', 'Michael',
      'Johny', 'Simpson'
    ],
    [NxTextColumn61.Index, NxTextColumn62.Index]);
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
  MatchingOptions := moContain;
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
  MatchingOptions := moBeginWith;
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
  MatchingOptions := moExactMatch;
end;

end.
