江
江西的delphi
Unregistered / Unconfirmed
GUEST, unregistred user!
1.小弟用stringgrid的DrawCell事件填充房屋数据,首行的每个cell放房屋层次,首列每个cell放房屋房间号,
其它cell放房屋号(房屋层次+房屋房间号);填充cell多时会有闪烁,而且stringgrid上面
浮动有其它窗体(form),当其它窗体(form)移动时,事件StringGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);就重绘,stringgrid闪的更厉害。
大家有没有好一点的方法,分可以再加。
2.如何得到某一cell的颜色
代码如下
procedure TF_HouseStatQuery.StringGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
if ADOQryHouse.Locate('sHouseID',(FormatFloat('00',ACol)+FormatFloat('00',ARow)),[]) then
begin
if Trim(ADOQryHouse.FieldByName('sSellState').AsString)='预定' then StringGrid.Canvas.Brush.Color := clFuchsia;
if Trim(ADOQryHouse.FieldByName('sSellState').AsString)='已售' then StringGrid.Canvas.Brush.Color := clRed;
if Trim(ADOQryHouse.FieldByName('sSellState').AsString)='未售' then StringGrid.Canvas.Brush.Color := clWindow;
if ADOQryHouse.FieldByName('bRetainState').AsBoolean then StringGrid.Canvas.Brush.Color := clLime;
StringGrid.Canvas.Lock;
StringGrid.Canvas.FillRect(Rect);
StringGrid.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, ADOQryHouse.FieldByName('sHouseID').AsString);
StringGrid.Canvas.Unlock;
end;
end;
其它cell放房屋号(房屋层次+房屋房间号);填充cell多时会有闪烁,而且stringgrid上面
浮动有其它窗体(form),当其它窗体(form)移动时,事件StringGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);就重绘,stringgrid闪的更厉害。
大家有没有好一点的方法,分可以再加。
2.如何得到某一cell的颜色
代码如下
procedure TF_HouseStatQuery.StringGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
if ADOQryHouse.Locate('sHouseID',(FormatFloat('00',ACol)+FormatFloat('00',ARow)),[]) then
begin
if Trim(ADOQryHouse.FieldByName('sSellState').AsString)='预定' then StringGrid.Canvas.Brush.Color := clFuchsia;
if Trim(ADOQryHouse.FieldByName('sSellState').AsString)='已售' then StringGrid.Canvas.Brush.Color := clRed;
if Trim(ADOQryHouse.FieldByName('sSellState').AsString)='未售' then StringGrid.Canvas.Brush.Color := clWindow;
if ADOQryHouse.FieldByName('bRetainState').AsBoolean then StringGrid.Canvas.Brush.Color := clLime;
StringGrid.Canvas.Lock;
StringGrid.Canvas.FillRect(Rect);
StringGrid.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, ADOQryHouse.FieldByName('sHouseID').AsString);
StringGrid.Canvas.Unlock;
end;
end;