Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.03.17;
Скачать: CL | DM;

Вниз

Новый class и его property   Найти похожие ветки 

 
BillyJeans ©   (2003-03-05 13:29) [0]

Создаю класс, который runtime создает форму с DBGrid, и никак не могу объявить свойство Columns, чтобы в палитре свойств можно было описывать столбцы создаваемого DBGrid....


 
Darlock   (2003-03-05 13:45) [1]

А в чем собственно проблема?


 
Dmitry Filippov ©   (2003-03-05 13:48) [2]


type
TMyGridColumnsProperty = class(TClassProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;

TMyGridColumnsPropertyEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;

procedure TMyGridColumnsPropertyEditor.ExecuteVerb(Index: Integer);
begin
if Index < inherited GetVerbCount then
inherited ExecuteVerb(Index) else
begin
Dec(Index, inherited GetVerbCount);
case Index of
0 :ShowCollectionEditor(Designer, Component,
TMyGrid(Component).Columns, "Columns");
end;
end;
end;

function TMyGridColumnsPropertyEditor.GetVerb(Index: Integer): string;
begin
if Index < inherited GetVerbCount then
Result := inherited GetVerb(Index) else
begin
Dec(Index, inherited GetVerbCount);
case Index of
0: Result := "?aaaeoi? eieiiie...";
1 : Result := "Reid & K";
end;
end;
end;

function TMyGridColumnsPropertyEditor.GetVerbCount: Integer;
begin
Result := inherited GetVerbCount + 2;
end;

procedure TMyGridColumnsProperty.Edit;
begin
ShowCollectionEditorClass(Designer, TDBGridColumnsEditor,
GetComponent(0) as TComponent, TMyGridColumns(GetOrdValue), GetName);
end;

function TMyGridColumnsProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;


procedure Register;
begin
RegisterPropertyEditor(TypeInfo(TMyGridColumns), TMyCustomDBGrid, "", TMyGridColumnsProperty);
RegisterComponentEditor(TMyCustomDBGrid, TMyGridColumnsPropertyEditor);
end;


 
Mike_Goblin ©   (2003-03-05 13:49) [3]

F1 TDBGridColumns
есть еще исходные тексты VCL и компонента TDBGrid, намек улавливаешь? :))))


 
BillyJeans ©   (2003-03-05 13:53) [4]

а вот не получается сделать так, чтобы в свойстве объявленных Columns можно было выбирать поле таблицы...


 
Dmitry Filippov ©   (2003-03-05 13:55) [5]

А таблица то есть


 
BillyJeans ©   (2003-03-05 14:12) [6]

в новом классе есть table, datasource и dbgrid...


 
BillyJeans ©   (2003-03-05 14:19) [7]

происходит следующая беда:
если в create класса пишу
FColumns := TDBGridColumns.Create(nil, TColumn);
то ругает на отсутствие owner;
если
FColumns := TDBGridColumns.Create(FDBGrid, TColumn);
то, при обращении к столбцу с индексом 1 вылетает Grid index out of range


 
Dmitry Filippov ©   (2003-03-05 14:28) [8]

попробуй FColumns:=TMyGrid.Columns;


 
BillyJeans ©   (2003-03-05 15:01) [9]

гы, а все и получилось!!!


 
BillyJeans ©   (2003-03-05 15:50) [10]

а если у у нового класса есть свойство FieldName, как сделать, чтобы в палитре выпадал список полей Table?



Страницы: 1 вся ветка

Текущий архив: 2003.03.17;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.02 c
6-54139
dimich1978
2003-01-25 15:15
2003.03.17
Передача текста через Tserversocket & TclientSocket ПЛИЗЗ ХЕЛП!!!


3-53855
Destroyer
2003-02-27 06:39
2003.03.17
Обновление Query


14-54158
Leon crom
2003-02-27 13:32
2003.03.17
мужчины потеют на 30% больше чем женщины


1-54081
Иванов Сергей
2003-03-04 22:35
2003.03.17
как создать панель типа таскбара


1-53974
Sanyok
2003-03-04 19:03
2003.03.17
Проблема с DLL