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