Topic: Disable / Enable a button
I wanted disable a button when there is nothing selected on tGrid and enable it when something selected on tGrid.
I tried this, didn't work:
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
if Form1.tgMainCustomers.SelectedRow = -1 then Form1.btnAddInvSelectedCust.Enabled := False else Form1.btnAddInvSelectedCust.Enabled := True;
This one didn't work too:
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
if Form1.tgMainCustomers.SelectedRow = -1 then Form1.btnAddInvSelectedCust.Enabled := False;
if Form1.tgMainCustomers.SelectedRow = 0 > then Form1.btnAddInvSelectedCust.Enabled := True;
end;
Ended up doing it with two procedures:
procedure Form1_tgMainCustomers_OnCellClick (Sender: TObject; ACol, ARow: Integer);
begin
Form1.btnAddInvSelectedCust.Enabled := True;
end;
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
if Form1.tgMainCustomers.SelectedRow = -1 then Form1.btnAddInvSelectedCust.Enabled := False;
end;
Isn't it possible doing with only:
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
......
end;
God... please help me become the person my dog thinks I am.