场景
我有一个相当复杂的表单,用于数据输入或不允许编辑的情况下查看,这取决于状态变量(窗体上的颜色和标题取决于状态)。它包含许多包含数据输入类型组件的面板。当在查看(非编辑)状态下,这些面板被设置为禁用,从而防止它们包含的任何组件被更改。
一个面板包含四个TRadioButtons和一个带有滚动条的备注框。由于备忘录中文本的数量,我仍然希望能够在视图模式下滚动备注框,以便将其全部读取。但是,我不希望更改备注文本或单选按钮。
我已经尝试过的
我没有禁用整个面板,而是将其保留为启用状态,只需将备忘框只读。这允许滚动,但不允许按需要编辑回忆录。
然而,由于面板是启用的,这意味着无线电按钮也是启用和可以改变。
如果我将每个无线电按钮的启用属性设置为false,则可以防止按需要更改它们,但这也会改变它们的外观并将其灰度化。
问题
我怎样才能防止用户改变这个面板上的无线电按钮,同时保持其外观不变,就好像它们是启用的,即不使它们变灰?
最小可重现性示例
procedure TFrmMember.ShowMemberForm(MemberDisplayMode: TMemberDisplayType);
begin
case FormDisplayMode of
<other stuff in a big case statement depending upon MemberDisplayMode>
ShowNoEdit: begin
SetFormDisplay(ShowNoEdit); //set colours and titles etc
DisableAllControls; //disable all panels on the form
//now enable scrolling of the comment memo content but don't allow edits
PanelComment.Enabled := True; //enable the panel containing the memo and 4 radiobuttons
MemoComment.ReadOnly := True; //don't allow editing of the memo
//now disable the radio buttons -THIS CHANGES APPEARANCE ??
RadioButtonCircEmail.Enabled := False;
RadioButtonCircPost.Enabled := False;
RadioButtonCircBoth.Enabled := False;
RadioButtonCircNone.Enabled := False;
<other stuff>
end;
<other stuff in a big case statement depending upon MemberDisplayMode>
end; //case
end; //procedure ShowMemberForm发布于 2020-10-11 17:41:01
在现有的面板上放置一个TPanel,并将RadioButtons移动到这个新的面板。或者,使用单个TRadioGroup,而不是在面板上放置单独的按钮。
然后,您可以只禁用新的面板/组,同时保持父面板启用,并将TMemo设置为只读。
https://stackoverflow.com/questions/64305296
复制相似问题