1.
procedure TForm1.ComboBox5Click(Sender: TObject);
begin
//
showmessage('hello');
end;
怎么单击它没反应啊?
2.
我想选出表中的 合同ID 并把它加到 ComboBox5的items中
query1.close;
Query1.SQL.Clear;
Query1.SQL.Text:='SELECT 合同ID FROM dbo.xinyuluru1 Dbo_xinyuluru1';
下一步该怎么办? ComboBox5Click没反应,该写到什么事件中?

解决方案 »

  1.   

    用一个循环加到它的items中就可以了
      

  2.   

    你的操作就是选出表中的 合同ID 并把它加到 ComboBox5的items中,不一定非要单机后,随便什么实践中加入都可以啊
      

  3.   

    能不能写具体一点,怎么用一个循环加到它的items中就可以了
    //关键是我不知道怎么得到选出的记录
      

  4.   

    query1.open;
    query1.first;
    while not query1.eof do]
      begin
        combobox1.items.add(query1.fieldvalues[]);
        query1.next;
      end;
    以上可以帮你实现第二个,地一个,你得添加item
      

  5.   

    combobox1.items.add(query1.fieldvalues[]);
    [Error] qyxy1.pas(248): Expression expected but ']' found
    []中应该添什么?
    下面写法对不对?
    query1.close;
    Query1.SQL.Clear;
    Query1.SQL.Text:='SELECT 合同ID FROM dbo.xinyuluru1 Dbo_xinyuluru1';
    query1.open;
    query1.first;
    while not query1.eof do
      begin
        combobox5.items.add(query1.FieldValues[] );
        query1.next;
      end;
      

  6.   

    fieldvalues[0],应该多看看delphi的help.
      

  7.   

    1.ComboBox有很多事件,Click事件是指你单击ComboBox框里面的内容。 我的经验是,当不确定是哪个事件时,在有可能的事件里面都写上ShowMessage() 比如,Click事件里写ShowMessage('Click')
           Select事件里写ShowMessage('Select');
           CloseUp事件里写ShowMessage('CloseUp');
    2.query1.close;
    Query1.SQL.Clear;
    Query1.SQL.Text:='SELECT 合同ID FROM dbo.xinyuluru1';
    query1.open;
    query1.first;
    while not query1.eof do
      begin
        combobox5.items.add(query1.FieldByName('合同ID').AsString );
        query1.next;
      end;
      

  8.   

    来晚了,楼上的对了。建议:各个事件都showmessage一下,有反映的就写
      

  9.   

    如果要实时获得 Combobox的改变值,就在 OnChange 事件里写代码吧.Proceudre Form1.Combobox5Change(Sender: TObject);
    Var
      NewID: Integer;
    Begin
      NewID:= StrToInt(Combobox5.Text);
      ...//在这里写入处理 NewID 的代码. 
    End;至于如何将"合同ID"添加到 Combobox,上面的朋友已经说得很清楚.但如果你不想一开始就加载,可以在 OnDropDown 事件里写如下代码;
    Procedure Form1.Combobox5DropDown(Sender: TObject);
    Begin
      IF Combobox5.Items.Count<>0 then Exit;
      query1.close;
      Query1.SQL.Text:='SELECT 合同ID FROM dbo.xinyuluru1';
      Try
        query1.open;
        while not query1.eof do
        begin
          combobox5.items.add(query1.FieldByName('合同ID').AsString );
          query1.next;
        end;
      Except
      End;
    End;
      
    End;
      

  10.   

    combobox5.items.clear;
    query1.close;
    Query1.SQL.Clear;
    Query1.SQL.Text:='SELECT 合同ID FROM dbo.xinyuluru1';
    query1.open;
    query1.first;
    while not query1.eof do
      begin
        combobox5.items.add(query1.FieldByName('合同ID').AsString );
        query1.next;
      end;
      

  11.   

    1.
    procedure TForm1.ComboBox5Select(Sender: TObject);
    begin
    //
    showmessage('hello');
    end;
    /////////////////////////
    2
    query1.close;
    Query1.SQL.Clear;
    Query1.SQL.Text:='SELECT 合同ID FROM dbo.xinyuluru1 Dbo_xinyuluru1';
    Query1.Open;
    ComboBox1.Clear;
    while not Query1.Eof do 
         begin
            ComboBox1.items.add(query1.FieldByName('合同ID').AsString );
         end; 
      

  12.   

    1.
    procedure TForm1.ComboBox5Click(Sender: TObject);
    begin
    //
     showmessage('hello');
    end;
    可能是你把事件沒有加到ONCLICK中去吧。
    2.
    我想选出表中的 合同ID 并把它加到 ComboBox5的items中
    query1.close;
    Query1.SQL.Clear;
    Query1.SQL.Text:='SELECT 合同ID FROM dbo.xinyuluru1 Dbo_xinyuluru1';
    combobox5.clear;
    with query1 do
    begin
      while not eof do
      begin
        combobox5.items.add(fieldbyname().asstring);
        next;
      end;
      close;
    end;