有一个按钮,开始是不可用的,但是我在选择combobox1和combobox2后就可以用了,请这个过程该怎样实现啊???

解决方案 »

  1.   

    开始时button1.enabled设置成False
    combobox1的OnEnter事件中写:
    Button1.Enabled:=True;
    Combobox1的onExit事件中写:
    Button1.Enabled:=False;Combobox2的OnEnter事件指向Combobox1的OnEnter事件
    combobox2的OnExit事件指向Combobox1的OnExit事件
      

  2.   

    这个是ComboBox1里有2项,选第一项时可用,第二项是不可用
    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
    if ComboBox1.ItemIndex=1 then
      button1.Enabled:=true;
    if ComboBox1.ItemIndex=0 then
      button1.Enabled:=false;
    end;
      

  3.   

    如果是必须对两个ComboBox都修改过才让BUTTON1有效是这样的:
    第一:先创一个窗体级的变量 
    t1,t2:boolean;第二:初如化,使BUTTON1不可用,且二个标识为假
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    t1:=false;
    t2:=false;
    button1.Enabled:=false;
    end;
    第三:
    设CHANGE事件,一个组件变化后,一个标识为真,当全为真时就BUTTON1有效
    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
    t1:=true;
    if t1 and t2 then
      button1.Enabled:=true;
    end;procedure TForm1.ComboBox2Change(Sender: TObject);
    begin
    t2:=true;
    if t1 and t2 then
      button1.Enabled:=true;
    end;