其他分享
首页 > 其他分享> > 给定 ComboBox 的默认值

给定 ComboBox 的默认值

作者:互联网

unit

 Unit1;

interfaceuses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls;

type

  TForm1 = class(TForm)
    ComboBox1: TComboBox;
    Button1: TButton;
    Button2: TButton;   

procedure

 FormCreate(Sender: TObject);    

procedure

 Button1Click(Sender: TObject);    

procedure

 Button2Click(Sender: TObject);  

end;

var

  Form1: TForm1;

implementation{$R *.dfm}procedure

 TForm1.FormCreate(Sender: TObject);

begin

  ComboBox1.Items.CommaText := 'aaa,bbb,ccc,ddd';

end;

procedure

 TForm1.Button1Click(Sender: TObject);

begin

  ComboBox1.ItemIndex := 1;

end;

procedure

 TForm1.Button2Click(Sender: TObject);

begin

  ComboBox1.ItemIndex := ComboBox1.Items.IndexOf('ccc');

end;

end.

标签:ComboBox1,end,Sender,ComboBox,TForm1,TObject,给定,默认值,procedure
来源: https://www.cnblogs.com/jijm123/p/14751953.html