我用stringgrid做输入界面,怎样根据第二列某个单元格输入以后,第五列相应的单元值也相应改变
for row:=1 to DataInputStringGrid.RowCount-1 do
    begin
      if DataInputStringGrid.Cells[2,row]='' then
        break;
    end;
      DataInputStringGrid.Cells[5,Row]:= floattostr(strtofloat(DataInputStringGrid.Cells[2,Row])*StrToFloat(Edit12.text));

解决方案 »

  1.   

    在StringGrid1KeyPress里面做]
    with DataInputStringGrid do
    if Col = 2 then
          Cells[5,Row]:= floattostr(strtofloat(Cells[2,Row])*StrToFloat(Edit12.text));
      

  2.   

    最好 StrToFloat  -> StrToFloatDef(*,0) 或其他
      

  3.   

    当我在col=2中输入的时候出现 '' is not a valid floating point value 怎么解决阿??
      

  4.   

    你要注意这句:with DataInputStringGrid do或者你直接用
    DataInputStringGrid.Col  当前列
    DataInputStringGrid.Row  当前行
    还有,注意StringGrid中的行和列是从0开始的!