如何将ComboBox中的部分选项设为不可选
解决方案 »
- 如何清除Combobox的所有元素。
- 简单问题数据显示问题,谢谢大家了。
- 请问,如何判断EDIT1里的值,是否被更改过?
- AtEnd := Temp = nil; 这是什么意识(50分在线等待)
- 关于DELPHI访问数据库的一个简单问题
- Delphi构造函数
- word中插入表格,并对表格进行操作
- 如何每天定时实现数据统计操作,使该应用程序形成的托盘图标实现监控功能,每天定时时间到时,就进行统计,完了之后继续监控。该应用程序
- 请教一个问题:如何将一个组件输出为一个DataSource或DataSet?
- 请问如何将数据库Table中的数据引入ActiveX页中的F1Book控件中
- delphi+sybase问题。关于cursor
- 小妹请各位帮帮忙,问题简单,在线等待!!!
begin
........
end
else
begin]
.........
end;
begin
ComboBox1.Text := '';
end;
将其他的选项过滤掉。你那种下拉框的用法很少见。
FNoSelectIndexs保存不可选的字符串在组合框中的索引unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
ComboBox1: TComboBox;
Edit1: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure Button1Click(Sender: TObject);
procedure ComboBox1Select(Sender: TObject);
private
FNoSelectItems:TStringList;
FNoSelectIndexs:TStringList;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
FNoSelectItems:=TStringList.Create;
FNoSelectIndexs:=TStringList.Create;
end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
FNoSelectIndexs.Free;
FNoSelectItems.Free;
end;procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
with ComboBox1.Canvas do
begin
FillRect(Rect);
if FNoSelectItems.IndexOf(ComboBox1.Items[index])<>-1 then
begin
Font.Color:=clGray;
FNoSelectIndexs.Add(inttostr(Index));
end; TextOut(Rect.Left,Rect.Top,ComboBox1.Items[index]);
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
FNoSelectItems.Add(edit1.Text);
end;procedure TForm1.ComboBox1Select(Sender: TObject);
begin
if FNoSelectIndexs.IndexOf(inttostr(ComboBox1.ItemIndex))<>-1 then
begin
ComboBox1.ItemIndex:=-1;
end;
end;end.