Mega Code Archive

 
Categories / Delphi / VCL
 

Showing dbgrid is disabled

Question: Some of the database components (notably the TDBGrid component) does not turn gray or give any visual notification when the control is disabled. How can I provide this functionability? Answer: The following example demonstrates changing the text color of the control to clGray when the control is disabled, giving a visual indication that the control is disabled. procedure TForm1.Button1Click(Sender: TObject); begin DbGrid1.Enabled := false; DbGrid1.Font.Color := clGray; end; procedure TForm1.Button2Click(Sender: TObject); begin DbGrid1.Enabled := true; DbGrid1.Font.Color := clBlack; end;