好象不能这样控制,不过你可以通过代码控制选择结果,如果不是红、绿、黄、黑四种颜色,就提示拥护重新选择
解决方案 »
- 关于Form的简单问题
- 对照片进行base64编码,解码
- ShellListView如何根据特定文件后缀名字过滤显示好像没有找到这个属性
- Cxgrid的checkbox勾选后,列明显资料自动排序
- 请问如何在表中更新指定的数据?在线给分
- 如何从txt将数据像从access中一样读出来
- 递归得到所有子控件出现了麻烦。
- 热点讨论:SQL的UPDATE将TABLE1的数据调到TABLE2中
- 请教各位:如何检测到键盘发出的控制字符?
- edit怎么用啊?
- 删除dbgrid中的记录问题
- 再次,为何delphi5读出Access2000的结构时,大部分字段类型(TFieldType)都为ftUnknown,如何能正确识别
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState); function ColorToBorderColor(AColor: TColor): TColor;
type
TColorQuad = record
Red,
Green,
Blue,
Alpha: Byte;
end;
begin
if (TColorQuad(AColor).Red > 192) or
(TColorQuad(AColor).Green > 192) or
(TColorQuad(AColor).Blue > 192) then
Result := clBlack
else if odSelected in State then
Result := clWhite
else
Result := AColor;
end;var
LRect: TRect;
LBackground: TColor;
vColor: TColor;
begin
with TComboBox(Control).Canvas do begin
FillRect(Rect);
LBackground := Brush.Color;
LRect := Rect;
LRect.Right := LRect.Bottom - LRect.Top + LRect.Left;
InflateRect(LRect, -1, -1);
IdentToColor(TComboBox(Control).Items[Index], Integer(vColor));
Brush.Color := vColor;
FillRect(LRect);
Brush.Color := ColorToBorderColor(ColorToRGB(Brush.Color));
FrameRect(LRect);
Brush.Color := LBackground;
Rect.Left := LRect.Right + 5;
TextRect(Rect, Rect.Left,
Rect.Top + (Rect.Bottom - Rect.Top - TextHeight(TComboBox(Control).Items[Index])) div 2,
TComboBox(Control).Items[Index]);
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Style := csOwnerDrawFixed;
ComboBox1.Items.Text := //红、绿、黄、黑
'clRed'#13#10 +
'clGreen'#13#10 +
'clYellow'#13#10 +
'clBlack'#13#10;
end;