Simple combobox el editor de la propiedad
El código siguiente muestra cómo crear un cuadro combinado de la propiedad del editor.
Prueba con Delphi 5
unidad de ComboTest
interfaz
usos
& nbsp & nbsp Windows, Messages, SysUtils, Classes, Graphics, Controles, Formularios, cuadros de diálogo,
& nbsp & nbsp StdCtrls, DsgnIntf
tipo
& nbsp & nbsp TEditList = clase(TEdit)
& nbsp & nbsp privada
& nbsp & nbsp & nbsp & nbsp FListValue: cadena
& nbsp & nbsp publicado
& nbsp & nbsp & nbsp & nbsp propiedad ListValue: cadena de leer FListValue escribir FListValue
& nbsp & nbsp final
procedimiento de Registro
aplicación
tipo
& nbsp & nbsp TTextProperty = clase(TPropertyEditor)
& nbsp & nbsp privada
& nbsp & nbsp & nbsp & nbsp Flista: TStringList
& nbsp & nbsp pública
& nbsp & nbsp & nbsp & nbsp constructor Create(const ADesigner: IFormDesigner
& nbsp & nbsp & nbsp & nbsp & nbsp & nbsp APropCount: Integer) reemplazar
& nbsp & nbsp & nbsp & nbsp destructor Destruir reemplazar
& nbsp & nbsp & nbsp & nbsp función GetValue: cadena de reemplazar
& nbsp & nbsp & nbsp & nbsp procedimiento SetValue(const Value: cadena) reemplazar
& nbsp & nbsp & nbsp & nbsp procedimiento GetValues(Proc: TGetStrProc) reemplazar
& nbsp & nbsp & nbsp & nbsp función GetAttributes: TPropertyAttributes reemplazar
& nbsp & nbsp final
procedimiento de Registro
begin
& nbsp & nbsp RegisterComponents('Muestras', [TEditList])
& nbsp & nbsp RegisterPropertyEditor(TypeInfo(string), TEditList,
& nbsp & nbsp & nbsp & nbsp 'ListValue', TTextProperty)
fin
{ TSList }
constructor TTextProperty.Crear(const ADesigner: IFormDesigner
& nbsp & nbsp APropCount: Integer)
begin
& nbsp & nbsp heredado Crear(ADesigner, APropCount)
& nbsp & nbsp Flista := TStringList.Crear
& nbsp & nbsp probar
& nbsp & nbsp & nbsp & nbsp Flista.LoadFromFile('c:/customstrings.txt')
& nbsp & nbsp excepto
& nbsp & nbsp & nbsp & nbsp Flista.Add('Elemento 1')
& nbsp & nbsp & nbsp & nbsp Flista.Add('Elemento 2')
& nbsp & nbsp final
fin
destructor TTextProperty.Destruir
begin
& nbsp & nbsp Flista.SaveToFile('c:/customstrings.txt')
& nbsp & nbsp Flista.Libre
& nbsp & nbsp heredado Destruir
fin
función TTextProperty.GetAttributes: TPropertyAttributes
begin
& nbsp & nbsp Resultado := [paValueList, paSortList]
fin
función TTextProperty.GetValue: string
begin
& nbsp & nbsp Resultado := (GetComponent(0) como TEditList).ListValue
fin
procedimiento TTextProperty.GetValues(Proc: TGetStrProc)
var
& nbsp & nbsp I: Longint
begin
& nbsp & nbsp for I := 0 a Flista.Contar -1
& nbsp & nbsp & nbsp & nbsp Proc(Flista.Strings[I])
fin
procedimiento TTextProperty.SetValue(const Value: string)
begin
& nbsp & nbsp (GetComponent(0) como TEditList).ListValue := Valor
& nbsp & nbsp si Flista.IndexOf(Valor) = -1 entonces
& nbsp & nbsp & nbsp & nbsp Flista.Agregar(Valor)
fin
final.
Simple combobox el editor de la propiedad
Simple combobox el editor de la propiedad : Multi-millones de consejos para hacer su vida mas facil.
El codigo siguiente muestra como crear un cuadro combinado de la propiedad del editor.
Prueba con Delphi 5
unidad de ComboTest
interfaz
usos
& nbsp & nbsp Windows, Messages, SysUtils, Classes, Graphics, Controles, Formularios, cuadros de dialogo,
& nbsp & nbsp StdCtrls, DsgnIntf
tipo
& nbsp & nbsp TEditList = clase(TEdit)
& nbsp & nbsp privada
& nbsp & nbsp & nbsp & nbsp FListValue: cadena
& nbsp & nbsp publicado
& nbsp & nbsp & nbsp & nbsp propiedad ListValue: cadena de leer FListValue escribir FListValue
& nbsp & nbsp final
procedimiento de Registro
aplicacion
tipo
& nbsp & nbsp TTextProperty = clase(TPropertyEditor)
& nbsp & nbsp privada
& nbsp & nbsp & nbsp & nbsp Flista: TStringList
& nbsp & nbsp publica
& nbsp & nbsp & nbsp & nbsp constructor Create(const ADesigner: IFormDesigner
& nbsp & nbsp & nbsp & nbsp & nbsp & nbsp APropCount: Integer) reemplazar
& nbsp & nbsp & nbsp & nbsp destructor Destruir reemplazar
& nbsp & nbsp & nbsp & nbsp funcion GetValue: cadena de reemplazar
& nbsp & nbsp & nbsp & nbsp procedimiento SetValue(const Value: cadena) reemplazar
& nbsp & nbsp & nbsp & nbsp procedimiento GetValues(Proc: TGetStrProc) reemplazar
& nbsp & nbsp & nbsp & nbsp funcion GetAttributes: TPropertyAttributes reemplazar
& nbsp & nbsp final
procedimiento de Registro
begin
& nbsp & nbsp RegisterComponents('Muestras', [TEditList])
& nbsp & nbsp RegisterPropertyEditor(TypeInfo(string), TEditList,
& nbsp & nbsp & nbsp & nbsp 'ListValue', TTextProperty)
fin
{ TSList }
constructor TTextProperty.Crear(const ADesigner: IFormDesigner
& nbsp & nbsp APropCount: Integer)
begin
& nbsp & nbsp heredado Crear(ADesigner, APropCount)
& nbsp & nbsp Flista := TStringList.Crear
& nbsp & nbsp probar
& nbsp & nbsp & nbsp & nbsp Flista.LoadFromFile('c:/customstrings.txt')
& nbsp & nbsp excepto
& nbsp & nbsp & nbsp & nbsp Flista.Add('Elemento 1')
& nbsp & nbsp & nbsp & nbsp Flista.Add('Elemento 2')
& nbsp & nbsp final
fin
destructor TTextProperty.Destruir
begin
& nbsp & nbsp Flista.SaveToFile('c:/customstrings.txt')
& nbsp & nbsp Flista.Libre
& nbsp & nbsp heredado Destruir
fin
funcion TTextProperty.GetAttributes: TPropertyAttributes
begin
& nbsp & nbsp Resultado := [paValueList, paSortList]
fin
funcion TTextProperty.GetValue: string
begin
& nbsp & nbsp Resultado := (GetComponent(0) como TEditList).ListValue
fin
procedimiento TTextProperty.GetValues(Proc: TGetStrProc)
var
& nbsp & nbsp I: Longint
begin
& nbsp & nbsp for I := 0 a Flista.Contar -1
& nbsp & nbsp & nbsp & nbsp Proc(Flista.Strings[I])
fin
procedimiento TTextProperty.SetValue(const Value: string)
begin
& nbsp & nbsp (GetComponent(0) como TEditList).ListValue := Valor
& nbsp & nbsp si Flista.IndexOf(Valor) = -1 entonces
& nbsp & nbsp & nbsp & nbsp Flista.Agregar(Valor)
fin
final.
Simple combobox el editor de la propiedad
By Consejos Y Trucos
Simple combobox el editor de la propiedad : Multi-millones de consejos para hacer su vida más fácil.