谢谢kingron的回答,我试了一下,StringGrid1DrawCell事件只能在窗体一弹出就发生了,但是我是要点击这个窗体另一个铵钮后,stringgrid的单元格才设置颜色。我是这样写的,但是不行。 procedure TForm6.ComboBox1Click(Sender: TObject); begin if form6.ComboBox1.Text='' then exit else begin themeunique:=form1.supermap1.layers[form2.combobox1.text].themeunique; themeunique.Field:=form6.ComboBox1.Text; form6.StringGrid1.RowCount:=themeunique.valuecount+1; flag:=1000; end; end;procedure TForm6.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var i:integer; begin if flag=1000 then begin acol:=0; for i:=0 to themeunique.ValueCount-1 do begin arow:=i; setbkcolor(stringgrid1.Canvas.Handle,themeunique.Style[i+1].brushcolor); end; end; end;
procedure TForm6.ComboBox1Click(Sender: TObject);
begin
if form6.ComboBox1.Text='' then
exit
else
begin
themeunique:=form1.supermap1.layers[form2.combobox1.text].themeunique;
themeunique.Field:=form6.ComboBox1.Text;
form6.StringGrid1.RowCount:=themeunique.valuecount+1;
flag:=1000;
end;
end;procedure TForm6.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
i:integer;
begin
if flag=1000 then
begin
acol:=0;
for i:=0 to themeunique.ValueCount-1 do
begin
arow:=i;
setbkcolor(stringgrid1.Canvas.Handle,themeunique.Style[i+1].brushcolor);
end;
end;
end;
在那个地方设置啊?我没有找到!如果有的话,那样是最简单了。
哎,你的问题上面没有说清楚!看看下面的代码!
procedure TForm1.Button1Click(Sender: TObject);
begin
stringgrid1.Canvas.Brush.Color:=clgreen;
stringgrid1.Canvas.FillRect(stringgrid1.CellRect(1,2))
end;
访问http://168.168.18.11:81/etechbase/advsearch.php将您的问题输入查询内容框,选择不同的精确程度,即可以找到你所需要的答案。效果还是可以的。