unit Prueba32; interface uses Classes,SysUtils, Db, DBGrids, Grids; type tdbp32= class; TMiColumn= Class(TColumn) private FPrueba: String; Fgrip: Tdbp32; procedure SetPrueba(value: String); public constructor create(collection: TCollection);override; destructor Destroy; override; procedure Assign(source: TPersistent); override; property Grid : tDbp32 read FGrip ; published property Prueba: string read FPrueba write SetPrueba; End; TMiGridColumn = Class(TDBGridColumns) function GetItem(AIndex: integer): TMiColumn; procedure SetItem(AIndex: integer; const Value: TMiColumn); public function Add: TMiColumn; // function IndexOf(ItemName:string):integer; // function ValueOf(ItemName:string):String; function ValueOfIndex(aIndex:integer):string; procedure Assign(Source: TPersistent); override; property Items[AIndex: integer] : TMiColumn read GetItem write SetItem; End; TDBP32 = class(TDBGrid) Private function GetColumns: TMiGridColumn; procedure SetColumns(Value: TMiGridColumn); protected { Protected declarations } function CreateColumns: TDBGridColumns; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; property Columns: TMiGridColumn read GetColumns write SetColumns; function ValueOfIndex(aIndex:integer):string; published end; procedure Register; implementation procedure Register; begin RegisterComponents('PRUEBAS', [tdbp32]); end; {TDBP32} Function TDBP32.GetColumns: TMiGridColumn; begin Result := TMiGridColumn(inherited Columns) end; procedure TDBP32.SetColumns(Value: TMiGridColumn); begin TMiGridColumn(Columns).Assign(Value) end; function TDBP32.CreateColumns: TDBGridColumns; begin Result := TDBGridColumns.Create(Self, TMiColumn); end; constructor TDBP32.Create(AOwner: TComponent); var Fcol:TDBGridColumns; begin inherited; Fcol:=TDBGridColumns.Create(Self, TMiColumn); end; destructor TDBP32.Destroy; begin inherited Destroy; end; function TDBP32.ValueOfIndex(aIndex:integer):string; begin result := Columns.ValueOfIndex(aIndex); end; {TMiGridColumn} function TMiGridColumn.GetItem(AIndex: Integer): TMiColumn; begin Result:= TMiColumn(inherited Items[aIndex]); end; procedure TMiGridColumn.SetItem(AIndex: integer; const Value: TMiColumn); begin inherited SetItem(AIndex, Value); end; function TMiGridColumn.Add: TMiColumn; begin Result:= TMiColumn(inherited Add); end; Function TMiGridColumn.ValueOfIndex(aIndex:integer):string; begin if (aIndex >=0) and (aIndex < Count) then Result:= items[aIndex].Prueba else Result:=''; end; procedure TMiGridColumn.Assign(Source: TPersistent); var V_valor:TMiGridColumn; V_loop: integer; begin if (Source is TMiGridColumn) then begin V_valor:=TMiGridColumn(Source); Clear; for V_loop := 0 to v_Valor.Count - 1 do add.Assign(v_Valor.Items[V_loop]); end Else Inherited; end; {TMicolumn} constructor TMiColumn.Create(collection: TCollection); begin inherited Create(collection); FPrueba:=''; end; Destructor TMiColumn.Destroy; begin inherited; end; procedure TMiColumn.SetPrueba(value: string); begin if FPrueba<>value then FPrueba:=value; end; procedure TMiColumn.Assign(source: TPersistent); var V_valor:TMiColumn; begin if (source is TMiColumn) then V_valor:=TMiColumn(source) else inherited; end; end.
lo que ocurre es que ahora no da fallos pero no puedo hacer la llamada convencionalmente
tdbp321.Columns[Column.ID].Prueba:='123';
tengo que hacerlo de la siguiente manera
tdbp321.Columns.Items[Column.ID].Prueba:='123';
Me podéis decir que estoy haciendo mal y si no es mucho pedir mostrarme el código con la corrección.