现在有两个TStringGrid,A和B,行列数是一模一样,现在我需要的是当我点B的cell(如:cells[5,5])时改变自己的cell的颜色,同时改变A中cell[5,5]的颜色,不是指的某行,而是小个的单元格背景色
解决方案 »
- 曲线取点求助
- 关于修改密码界面的问题
- 再次恭喜华仔升3星
- 祝贺D版所有的朋友新年快乐,万事如意。也庆祝自己在csdn注册7年了,得到了大家很多的帮助,谢谢大家,谢谢CSDN
- 慢的向蜗牛!!急呀??
- 哪里有像Windows的任务栏那样能控制MDI子窗口激活的ToolBar控件啊?
- 如何动态创建按钮?以及如何让其响应click事件!
- adoquery的问题,急,急,急!!!
- 怎么样读出sybase数据库里所有的表名,急~~~~~~~~谢谢!
- dll的运行语句应该是在那里,以上的代码望各位大虾阅读后给点解答(关注有分)
- 急求fastreport最简单的统计
- DELPHI7下的idTcpClient和idTcpServer控件的数据接收问题
Rect: TRect; State: TGridDrawState);
begin
if (ACol =5) and (ARow = 5) then
begin
StringGrid1.Canvas.Brush.Color := clRed;
StringGrid1.Canvas.FillRect(Rect);
end;
end;
Canvas.TextOut
要不没文字
Rect: TRect; State: TGridDrawState);
begin
StringGrid2.Canvas.Brush.Color:=clWindow;
StringGrid2.Canvas.FillRect(stringgrid1.CellRect(acol,arow));//恢复默认
if (StringGrid1.Row =2) and (StringGrid1.Col = 2) then//去掉这行,点那个CEll,那个cell变
begin
StringGrid1.Canvas.Brush.Color := clRed;
StringGrid1.Canvas.FillRect(stringgrid1.CellRect(StringGrid1.Col,StringGrid1.Row));
stringgrid1.canvas.textout(rect.left,rect.top,StringGrid1.cells[acol,arow]);
StringGrid2.Canvas.Brush.Color := clRed;
StringGrid2.Canvas.FillRect(stringgrid2.CellRect(StringGrid1.Col,StringGrid1.Row));
stringgrid2.canvas.textout(rect.left,rect.top,StringGrid1.cells[acol,arow]);
end;
end;
str: string;
begin
if (ACol =5) and (ARow = 5) then
begin
Canvas.Brush.Color := clRed;
Canvas.fillrect(ARect);
str := trim(StringGrid1.Cells[ACol, ARow]);
DrawText(Canvas.Handle, PChar(str), Length(str), ARect, DT_LEFT or DT_SINGLELINE or DT_VCENTER);
end;
end;
end;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
inherited;
with DBGridEh2 do
begin
if (Column.Index=DBGridEh2.FieldColumns['byBPRICE'].Index)
and (DBGridEh2.DataSource.DataSet.FieldByName('byBPRICE').AsFloat>DBGridEh2.DataSource.DataSet.FieldByName('LOWPRICE').AsFloat*(1+0.02)) then
begin
Canvas.Brush.Color := clRed;
DefaultDrawDataCell(Rect, Column.Field, State);
end;
end; 你改下吧 我用的是DBGridEh
Rect: TRect; State: TGridDrawState);
var
R,Rex:TRect;
fontCl:TColor;
i,j:Integer;
str:string;
begin
Caption:=Format('left:%d top:%d bott:%d right:%d ==== 行:%d 列:%d',[ R.Left,R.Top,r.Bottom,r.Right,ARow,acol]); StringGrid2.Canvas.Brush.Color:=clWindow;
StringGrid2.Canvas.FillRect(stringgrid1.CellRect(acol,arow));//恢复默认
StringGrid1.Canvas.Brush.Color := clYellow;
StringGrid1.Canvas.FillRect(stringgrid1.CellRect(StringGrid1.Col,StringGrid1.Row)); StringGrid2.Canvas.Brush.Color := clRed;
StringGrid2.Canvas.FillRect(stringgrid2.CellRect(StringGrid1.Col,StringGrid1.Row));
stringgrid2.canvas.textout(rect.left,rect.top,StringGrid2.cells[acol,arow]);end;
这是事件code,点grd1点一个格时,grd2里有时文字会给覆盖.有什么好办法没有???