T
tangyan
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在录入的同时,判断用户是否是输入的国家单词,如果是就用红色显示,如下是我的代码,但总不能如愿,大家帮帮忙,马上结贴.procedure TForm1.DBGridEh1SetEditText(Sender: TObject; ACol, ARow: Integer; const Value: String);var lRect:TRect; ls_Char:String[1]; ls_Country:String; li_Width:integer;begin ls_Char := Copy(Value,length(Value),1); lRect := (Sender As TDbGridEh).Columns.Grid.CellRect(ACol,ARow); if ls_Char=' ' then begin //如果两个空格间是一个国家 ls_Country := GetCountryWord(trim(Value)); if ls_Country <>'' then begin li_Width := Canvas.TextWidth(Value) - Canvas.TextWidth(ls_Country); lRect.Left := lRect.Left+li_Width; (Sender As TDbGridEh).Canvas.Font.Color:=Clred; (Sender As TDbGridEh).Canvas.fillrect(lRect); (Sender As TDbGridEh).Canvas.textout(lRect.left,lRect.top+2,ls_Country ); end; end;end;基本实现了功能,但是在录入下一个单词时,前一个国家单词的颜色又变成黑色了,怎么办啊???有其他方法