请问:怎样获得DBgrid当前单元格输入的字符个数?

解决方案 »

  1.   

    function GetLength(Grid: TDBGrid): Integer;
    var
      Edit: TCustomEdit;
    begin
      Result := 0;
      for I := 0 to Grid.ComponentCount - 1 do
        if Grid.Components[I] is TCustomEdit then
        begin
          Edit := TCustomEdit(Grid.Components[I]);
          if Edit.Visible and Edit.Focused then
          begin
            Result := Length(Edit.Text);
            break;
          end;
        end;
    end;
      

  2.   

    DBGrid OnKeyUp事件
      with Sender as TDBGrid do
        I := Length(((Controls[0] as TInPlaceEdit).Text));
    解决问题了记得给我加分啊 :)