大家好,请教大家一个程序的问题
大家好,我是个新手。接触delphi几天,看书上的一个例子,做出来结果跟我想象的不一样,请大家帮忙看看。选票内容里为什么不能显示“我最喜欢的手机品牌有:”和“最近想购买的大件商品”呢?谢谢各位。。unit Unit4_3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, CheckLst, ComCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
ListBox1: TListBox;
Label2: TLabel;
CheckListBox1: TCheckListBox;
Label3: TLabel;
ComboBox1: TComboBox;
RichEdit1: TRichEdit;
Label4: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
Item:integer;
begin
RichEdit1.Lines[0]:='我最喜欢的PC机品牌有:';
RichEdit1.Lines[1]:=''; //PC机品牌
for Item:=0 to ListBox1.Items.Count-1 do
if ListBox1.Selected[Item] then
RichEdit1.Lines[1]:=RichEdit1.Lines[1]+ListBox1.Items.Strings[Item]+' ';
RichEdit1.Lines[3]:='我最喜欢的手机品牌有:';
RichEdit1.Lines[4]:=''; //手机品牌
for Item:=0 to CheckListBox1.Items.Count-1 do
if CheckListBox1.Checked[Item] then
RichEdit1.Lines[4]:=RichEdit1.Lines[4]+CheckListBox1.Items.Strings[Item]+' ';
RichEdit1.Lines[6]:='我最近想买'+ComboBox1.Text;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Item:integer;
begin
for Item:=0 to ListBox1.Items.Count-1 do
ListBox1.Selected[Item]:=false;
for Item:=0 to CheckListBox1.Items.Count-1 do
CheckListBox1.Checked[Item]:=false;
for Item:=0 to RichEdit1.Lines.Count-1 do
RichEdit1.Lines[Item]:='';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;
end.