stringgrid中值如下 1 2 3 2 4 5 6 4 6我点中其中的一个2的cell ,该cell与另外一个2的cell同变成一个颜色,点到其他cell上,两个cell还变成原来的颜色要求:不要重新刷新,上面只是我举的例子,实际过程中cell比较多,刷新的话会很慢
解决方案 »
- 中秋节散分
- 请问adoquery在access数据库中能否使用事务,谢谢
- 请问如何知道现在指针在数据表的第几行?
- 关于MessageBox,MessageDlg的用法!
- 如何在移动鼠标到listview列头的时候改变字体颜色?
- 请问如何将Panel变成透明的?
- 请问各位大侠,怎样是DBGrid中的某些满足条件的记录显示的颜色与其他的记录的显示颜色不同?
- 如何知道popupmenu点击了哪一项?
- 帮忙指点!小弟想实现最简单的从服务器端查询到数据!!!
- 都是微软惹的祸-----Excel的新问题,急急急!!!
- 明天结婚纪念日,散分。来着有份!
- 点击按钮后,从数据库取出一个字符串并打开该字符串同名的窗体
不刷新能达到你要求就怪了
然后找出值相同的进行变色 其他的不用变
Canvas.Invalidate;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if StringGrid1.Cells[ACol,ARow] = '选中的值' then
begin
StringGrid1.Canvas.Brush.Color := clRed;
StringGrid1.Canvas.FillRect(Rect);
StringGrid1.Canvas.Font.Color := clWhite;
StringGrid1.Canvas.TextOut(Rect.Left,Rect.Top,StringGrid1.Cells[ACol,ARow]);
end;
end;
//改改楼上的procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
begin
Caption:= StringGrid1.Cells[ACol,ARow];
StringGrid1.Refresh;
end;procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if StringGrid1.Cells[ACol,ARow] = Caption then
begin
StringGrid1.Canvas.Brush.Color := clRed;
StringGrid1.Canvas.FillRect(Rect);
StringGrid1.Canvas.Font.Color := clWhite;
end else
begin
StringGrid1.Canvas.Brush.Color := clWhite;
StringGrid1.Canvas.FillRect(Rect);
StringGrid1.Canvas.Font.Color := clBlack;
end;
StringGrid1.Canvas.TextOut(Rect.Left,Rect.Top,StringGrid1.Cells[ACol,ARow]);
end;