![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
StringGrid, InplaceEdit, MaxLength
kmc © (2002-04-16 14:11:00)Всем привет.
Как установить максимальную длину вводимой строки в
TStringGrid?
GetEditMask не катит.
MBo (2002-04-16 15:21:00) [1]>Song
не буянь ;)
Song (2002-04-16 15:01:00) [2]Устали ждать???? Я выдал Вам 100% рабочий вариант (по-моему лучше Вашего на мой взгляд) уже через 10 мин, 2 минуты скиньте на написание и проверку, а ещё я не сразу увидел Ваш вопрос :))
kmc (2002-04-16 14:54:00) [3]Всем большое спасибо, но я устал ждать и сделал сам,
причем довольно-таки красиво:
unit MlGrid;
interface
uses Classes, Grids;
type
TGetEditLimitEvent = procedure (Sender: TObject; ACol, ARow: Longint;
var Value: Integer) of object;
TMlStringGrid = Class(TStringGrid)
private
FOnGetEditLimit : TGetEditLimitEvent;
published
property OnGetEditLimit : TGetEditLimitEvent read FOnGetEditLimit write
FOnGetEditLimit;
protected
function GetEditLimit : Integer; override;
end;
procedure Register;
implementation
function TMlStringGrid.GetEditLimit;
begin
OnGetEditLimit(Self, Col, Row, Result);
end;
procedure Register;
begin
RegisterComponents("Mye", [TMlStringGrid]);
end;
end.
MBo (2002-04-16 14:33:00) [4]
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
begin
StringGrid1.Tag:=Acol+100*Arow;
end;
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if key<>#8 then
with stringgrid1 do
if length(cells[tag mod 100,tag div 100])>=MaxLen
then key:=#0;
end;
Song (2002-04-16 14:21:00) [5]Вот, прикольный вариант: :))
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer; const Value: String);
Const MaxLength=5;
begin
IF Length(Value)>MaxLength then
Begin
keybd_event(VK_BACK,0,0,0);
Application.ProcessMessages;
keybd_event(VK_BACK,0,KEYEVENTF_KEYUP,0);
End;
end;