我们将Delphi 10与DevExpress V19.2.4一起使用。
cxMyRTTIInspector1.InspectedObject := myObject;
[我们有10行,我发现第一行是ReadOnly
,其余9行是可编辑的(粗体),(尽管我们有源代码,但我不知道为什么会这样)]
是否可以将行设置为只读?谢谢
您可以通过这种方式强制无法从TcxRTTIInspector
编辑属性:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, cxGraphics, cxControls,
cxLookAndFeels, cxLookAndFeelPainters, cxStyles, dxScrollbarAnnotations,
cxEdit, cxInplaceContainer, cxVGrid, cxOI;
type
TForm1 = class(TForm)
cxRTTIInspector1: TcxRTTIInspector;
procedure cxRTTIInspector1ItemChanged(Sender: TObject;
AOldRow: TcxCustomRow; AOldCellIndex: Integer);
procedure FormCreate(Sender: TObject);
private
FForcedReadOnlyProperty : string;
{ Private declarations }
public
function IsForcedReadOnlyProperty(const APropertyName : string) : boolean;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.IsForcedReadOnlyProperty(const APropertyName : string) : boolean;
begin
Result := FForcedReadOnlyProperty = APropertyName;
end;
procedure TForm1.cxRTTIInspector1ItemChanged(Sender: TObject;
AOldRow: TcxCustomRow; AOldCellIndex: Integer);
begin
TcxRTTIInspector(Sender).OptionsData.Editing := (
Assigned(TcxRTTIInspector(Sender).FocusedRow) and
(not IsForcedReadOnlyProperty(TcxPropertyRow(TcxRTTIInspector(Sender).FocusedRow).Properties.Caption))
);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FForcedReadOnlyProperty := 'Caption';
cxRTTIInspector1.InspectedObject := Self;
end;
end.
如果要突出显示这些属性,则可以使用Styles.OnGetContentStyle
和/或Styles.OnGetHeaderStyle
事件处理程序来完成