请问怎么屏蔽ComboBox中的选项,等待。

sfxllj 2003-04-18 10:21:17
在ComboBox中怎么让他的个别选项变灰,即不可选?谢谢赐教!
...全文
37 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dht2003 2003-04-18
  • 打赏
  • 举报
回复
up
u2m 2003-04-18
  • 打赏
  • 举报
回复
把 CommoBox.Style:=csOwnerDrawVariable或者csOwnerDrawFixed
然后在ComboBox1DrawItem事件中做判断和绘图
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
rt: TRect;
begin
with ComboBox1.Canvas do
begin
rt := Rect;
Brush.Color := clBtnFace;
FillRect(rt);
//if 做判断哪个要变灰 then
Font.Color := clGrayText;
DrawText(Handle, PChar(ComboBox1.Items.Strings[0]),
-1, rt, DT_CENTER or DT_VCENTER or DT_BOTTOM);
end;
end;
gongzhijia 2003-04-18
  • 打赏
  • 举报
回复
up
qwertyasd 2003-04-18
  • 打赏
  • 举报
回复
procedure TForm1.ComboBox1Click(Sender: TObject);
begin
if ComboBox1.ItemIndex=1 then ComboBox1.ItemIndex:=-1;
end;
智商无下限 2003-04-18
  • 打赏
  • 举报
回复
上面的方法好像只是变灰了但还是可以选择的吧。
建议既然你不让用户选了为什么不暂时把他删掉哪?用的时候在加回去!

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧