高手诊断delphi条件语句

来源:百度知道 编辑:UC知道 时间:2024/05/16 13:46:44
procedure TForm1.ComboBox2Click(Sender: TObject);
begin
if combobox1.Text='初中'then
begin
if combobox2.Itemindex=0 then //选中第1册
begin
combobox3.Clear ;
combobox3.Text:='选择篇目';
combobox3.Items.Add('敕勒歌');
combobox3.Items.Add('为学');
end;
if combobox2.Itemindex=1then //选中第2册
begin
combobox3.Clear ;
combobox3.Text:='选择篇目';
combobox3.Items.Add('春江晚景');
combobox3.Items.Add('口技');
end;
if combobox2.Itemindex=2then //选中第3册
begin
combobox3.Clear ;
combobox3.Text:='选择篇目';
combobox3.Items.Add('望天门山');
combobox3.Items.Add('春夜喜雨');
end ;
if combobox2.Itemindex=3then //选中第4册
begin
combobox3.Clear ;
combobox3.Text:='选择篇目';
combobox3.Items.Add('晓出静慈寺送林子方');

没细心看程序,但感觉你这样思路本来就不太好;
如果改成数据库,用主从表的话,用DBLOOKUPCOMBOBOX基本上不用写代码就可以做到,而且随时可以向数据库加新篇目, 像你这样写, 如果加一个新篇目,你就要改代码, 不是种好思路,软件的扩展性也太差;