5,929
社区成员




procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
aRect : TRect;
begin
aRect := Rect;
aRect.Right := Rect.Right;
aRect.Left := Rect.Left+80;
ComboBox1.Canvas.Font.Color := clBlue;
ComboBox1.Canvas.TextRect(Rect,Rect.Left,Rect.Top,ComboBox1.Items[index]);
ComboBox1.Canvas.Font.Color := clRed;
ComboBox1.Canvas.TextRect(aRect,aRect.Right-20,aRect.Top,'X');
end;
//x去掉就去掉呗
ComboBox1.Canvas.TextOut(Rect.Right - 16,Rect.Top,'');
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
ComboBox1.Canvas.Font.Color := ComboBox1.Font.Color;
ComboBox1.Canvas.TextOut(Rect.Left,Rect.Top,ComboBox1.Items.Strings[index]);
ComboBox1.Canvas.Font.Color := clRed;
ComboBox1.Canvas.TextOut(Rect.Right - 16,Rect.Top,'x');
end;