mirror of
https://github.com/rickrd/crud-delphi.git
synced 2025-12-19 09:03:43 +01:00
added 'search by name' function
This commit is contained in:
parent
fe90e396e3
commit
9131da2ccf
@ -1,8 +1,8 @@
|
||||
object FormGrid: TFormGrid
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 365
|
||||
Height = 340
|
||||
Width = 448
|
||||
Height = 418
|
||||
AutoScroll = True
|
||||
Caption = 'FormGrid'
|
||||
Color = clBtnFace
|
||||
@ -17,6 +17,13 @@ object FormGrid: TFormGrid
|
||||
OnClose = FormClose
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Label1: TLabel
|
||||
Left = 48
|
||||
Top = 228
|
||||
Width = 46
|
||||
Height = 13
|
||||
Caption = 'Pesquisa:'
|
||||
end
|
||||
object StringGrid1: TStringGrid
|
||||
Left = 8
|
||||
Top = 35
|
||||
@ -33,16 +40,17 @@ object FormGrid: TFormGrid
|
||||
object ToolBar1: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 349
|
||||
Width = 432
|
||||
Height = 29
|
||||
ButtonHeight = 25
|
||||
ButtonHeight = 21
|
||||
Caption = 'ToolBar1'
|
||||
TabOrder = 1
|
||||
ExplicitWidth = 349
|
||||
object btExcluir: TButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 70
|
||||
Height = 25
|
||||
Height = 21
|
||||
Caption = 'Excluir'
|
||||
TabOrder = 0
|
||||
OnClick = btExcluirClick
|
||||
@ -51,11 +59,19 @@ object FormGrid: TFormGrid
|
||||
Left = 70
|
||||
Top = 0
|
||||
Width = 70
|
||||
Height = 25
|
||||
Height = 21
|
||||
Caption = 'Escolher'
|
||||
Default = True
|
||||
TabOrder = 1
|
||||
OnClick = btEscolherClick
|
||||
end
|
||||
end
|
||||
object edPesquisa: TEdit
|
||||
Left = 100
|
||||
Top = 225
|
||||
Width = 121
|
||||
Height = 21
|
||||
TabOrder = 2
|
||||
OnChange = edPesquisaChange
|
||||
end
|
||||
end
|
||||
|
||||
@ -13,12 +13,16 @@ type
|
||||
ToolBar1: TToolBar;
|
||||
btExcluir: TButton;
|
||||
btEscolher: TButton;
|
||||
edPesquisa: TEdit;
|
||||
Label1: TLabel;
|
||||
procedure geraGrid(wLista: TLista; wClass: TClass);
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
procedure btExcluirClick(Sender: TObject);
|
||||
procedure btEscolherClick(Sender: TObject);
|
||||
procedure edPesquisaChange(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
palavra: string;
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
@ -64,6 +68,42 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TFormGrid.edPesquisaChange(Sender: TObject);
|
||||
var
|
||||
wString: string;
|
||||
wCont: integer;
|
||||
wObj: TObject;
|
||||
wCont2: integer;
|
||||
wCheckString: string;
|
||||
wLista: TLista;
|
||||
begin
|
||||
palavra := edPesquisa.Text;
|
||||
wCheckString := '';
|
||||
wLista := TLista.Create;
|
||||
for wCont := 0 to FLista.Count-1 do
|
||||
begin
|
||||
wObj := FLista.getObjectByIndex(wCont);
|
||||
if FClass = TCidade then
|
||||
begin
|
||||
with wObj as TCidade do
|
||||
begin
|
||||
for wCont2 := 1 to wCidade.Length do
|
||||
begin
|
||||
wCheckString := wCheckString + Copy(wCidade, wCont2, 1);
|
||||
if wCheckString = palavra then
|
||||
begin
|
||||
ShowMessage(wCheckString);
|
||||
wLista.Inserir(wObj, TCidade);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
FormGrid.geraGrid(wLista, TCidade);
|
||||
|
||||
end;
|
||||
|
||||
procedure TFormGrid.FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
begin
|
||||
Action := caFree;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user