Por fin, solucionado.
Es curioso, pero de esta forma me da error.
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if DBGrid1.Fields[DBGrid1.SelectedIndex]=(DBGrid1.DataSource.DataSet.FieldByName('Author')) then
begin
if DBGrid1.Controls[0] is TInPlaceEdit then
with DBGrid1.Controls[0] as TInPlaceEdit do
begin
if (GetTextLen >= MaxLongComment) and (Key <> #8) then
begin
Key := #0;
ShowMessage('Máxima longitud alcanzada');
end;
end;
end;
end;
Y de la siguiente forma, funciona:
Columna:=DBrejilla.SelectedIndex; // Averigua numero de columna posicionada.
if columna=1 then
begin
if dbrejilla.Controls[0] is TInPlaceEdit then
with dbrejilla.Controls[0] as TInPlaceEdit do
begin
if (GetTextLen >= 20) and (Key <> #8) then
begin
Key := #0;
ShowMessage('Máxima longitud alcanzada');
end;
end;
end;
Perdon por la indentación, pero no logro que se respete.
Gracias a todos y en especial a nlsgarcia.
Última edición por dvd2000 fecha: 08-12-2012 a las 15:19:59.
|