我想创建一个函数,它应该支持TListbox或TChecklistBox作为调用参数
MyUISupportFunction ( ...... ; aListBox : TObject);
if (aListBox as TObject) is TListBox then (aListBox as TListbox).Items.Clear;
if (aListBox as TObject) is TCHeckListBox then (aListBox as TCheckListbox).Items.Clear;我想知道我能不能在两个UI (TListBox和TChechecklist Box)上都能更高效地编写代码
发布于 2013-03-26 21:42:17
两者都继承自TCustomListBox
Procedure MyUISupportFunction (aListBox : TCustomListBox);
begin
aListBox.Items.Clear;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyUISupportFunction(Listbox1);
MyUISupportFunction(CheckListBox1);
end;https://stackoverflow.com/questions/15638543
复制相似问题