(dbgrid)
刚好手头的客户管理模块做到这里,顺便给你贴过来。客户信誉度=极差时用红色。
{ Fixed the record with red color where Cust_Grade is very bad }
procedure TCustmanaFrm.dbgCustmanaBrowseDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if Vartostr(Qry_Dbgrid['Cust_Grade'])='极差' then
dbgCustmanaBrowse.Canvas.Font.Color := clRed;
dbgCustmanaBrowse.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
不让修改某行(客户信誉度=极差时不让其修改):
procedure TCustmanaFrm.dbgCustmanaBrowseColEnter(Sender: TObject);
begin
if Vartostr(Qry_Dbgrid['Cust_Grade'])='极差' then
{only remove dgediting from the (dbgrid)options }
dbgCustmanaBrowse.Options:=[dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgTabs,dgRowSelect,dgConfirmDelete,dgCancelOnExit]
else
dbgCustmanaBrowse.Options:=[dgediting,dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgTabs,dgRowSelect,dgConfirmDelete,dgCancelOnExit];
{only add dgediting to the options }
end;