delphi中的add到底是函数还是方法?

来源:百度知道 编辑:UC知道 时间:2024/07/05 07:16:38
delphi中的add到底是函数还是方法?我添加了1个ListBox1控件,然后按F1帮助,在method里面没看到有add这个方法,我翻译了下,是添加,增加的意思,难道它是系统内置的函数?小弟初学编程,望各位大哥指点,谢谢!

是TStrings 下的一个函数,
这是在TStrings下定义的这个函数
function Add(const S: string): Integer; virtual;

Description

Call Add to add a string to the end of the list. Add returns the index of the new string.
返回值是添加后的序号: returns the index of the new string.

Items属性, memo的Lines 属性,都属于TStrings 对象.

你自己创建个一个TStrings;

var ss:TStrings;
ss:=TStringList.create();
ss.add('abc');

帮助中你看看ListBoxs的Items属性,就是一个TStrings

------------摘自delphi 帮助------------
Contains the strings that appear in the list box.

property Items: TStrings;

Description

Use Items to add, insert, delete and move items. By default, the items in a list box are of type TStrings. Use this item type to access its methods or properties to manipulate the items in the list.

For example, the following code adds the text in the edit box to the list box as an item:

ListBox1.Items.Add(Edit1.