04.06.2005, 00:24
общий
это ответ
Здравствуйте, Ujin Antikvar!
А как у тебя с английским???
TMyGrid и TMyGrids идут через 1
ЧТО ТАКОЕ ЗА IF KEY= ... ??? Если просто параметр, то ему не место здесь, если
обработчик OnKeyPress - заменяй OnKeyPress у родителя так же как и Constructor
Кстати конструктор криво написан, все методы в Protected - это бред(я бы сказал что лучше в public, но это уже философский вопрос).
Идём дальше:
Property TextCols: TStrings read GetCols write SetCols;
Это наоборот в Protected надо, а уже Read&Write будут делать то что надо!
В общем чистая матчасть,ничего с чем стоило бы обращаться к экспертам, а сначала элементарно почитать что пишет компилятор.
Приложение:
unit MyGrid;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls;type TMyGrids = class(TStringGrid) private { Private declarations } protected Procedure SetCols(Value: TStrings); Function GetCols : TStrings; Procedure SetRows(Value: TStrings); Function GetRows : TStrings; { Protected declarations } public Procedure ShowGrids(key:cardinal);//????? Constructor Create(AOwner: TComponent); override; { Public declarations } published // Первая колонка Property TextCols: TStrings read GetCols write SetCols; // Первая строка Property TextRows: TStrings read GetRows write SetRows; { Published declarations } end;procedure Register;implementation{*.tmg}Constructor TMyGrids.Create(AOwner: TComponent);begininherited Create(AOwner); ColCount := 2; DefaultRowHeight := 20;end;Procedure TMyGrids.SetCols(Value: TStrings);begin if Value.Count > RowCount then RowCount := Value.Count; Cols[0].Assign(Value);end;Function TMyGrids.GetCols: TStrings;begin result := Cols[0];end;Procedure TMyGrids.SetRows(Value: TStrings);begin if Value.Count > ColCount then ColCount := Value.Count; Rows[0].Assign(Value);end;Function TMyGrids.GetRows: TStrings;begin result := Rows[0];end;Procedure TMyGrids.ShowGrids(key:cardinal);begin if Key = VK_F11 then //ЧТО ЭТО???!!! ShowMessage(‘Name = ‘+Name+#10#13#10+‘RowCount = ‘+IntToStr(RowCount)+ #10#13#10+‘ColCount = ‘+IntToStr(ColCount)+#10#13#10+‘FixedRows = ‘+ IntToStr(FixedRows)+#10#13#10+‘FixedCols = ‘+IntToStr(FixedCols)+#10#13#10 +‘Left = ‘+IntToStr(Left)+#10#13#10+‘Top = ‘+IntToStr(Top));end;procedure Register;begin RegisterComponents(‘Ujin Antikvar component‘, [TMyGrids]);end;end.