请问如何将stringgird控件和combobox关联起来?
   也就是说选择combobox中不同的数值,stringgrid即给出相对应的表格

解决方案 »

  1.   

    在Combox的Onchange里面写
    Case Combobox1.ItemIndex of
     0 : begin
         end;
     1 : begin
         end;
    else 
        begin
        end;
    end;
      

  2.   

    那要你自已写代码。
    在下拉框的事件中写,如果combobox内容改变了,就相应的改stringgrid的显示不就行了?用的着跪吗?真的是,起来。
      

  3.   

    procedure TForm1.StringGrid1SelectCell(Sender: TObject;
      ACol, ARow: Integer; var CanSelect: Boolean);
    begin
      ComboBox1.Visible := False;
      ComboBox2.Visible := False;
      ComboBox1.Left := StringGrid1.Left + StringGrid1.CellRect(ACol, ARow).Left + 2;
      ComboBox1.Top := StringGrid1.Top + StringGrid1.CellRect(ACol, ARow).Top + 1;
      ComboBox1.Height := StringGrid1.RowHeights[ARow] + 3;
      ComboBox1.Width := StringGrid1.ColWidths[ACol] + 4;
    end;
      

  4.   

    忘了 后边还得combobox1.visible:=true;
      

  5.   

    我的程序里没有ComboBox2呀??
      

  6.   

    在combobox1的onchange事件中加入stringgrid1的更新代码