当我单击 TListView 选定项但不完全禁用它时,我想禁用进入编辑模式(设置属性 ReadOnly=True)。我希望仍然能够通过其他方法对其进行编辑。有可能的 ?
问问题
2376 次
1 回答
3
我没有看到任何简单的方法来准确检测LVN_BEGINLABELEDIT
通知是如何产生的。它LVN_BEGINLABELEDIT
是触发列表视图就地编辑的通知。
所以,我认为你可能需要想出一个稍微老套的解决方案。在表单中添加一个字段,例如Boolean
命名。FCanEditListView
然后,无论您在哪里触发编辑模式,都在触发编辑模式之前设置此标志True
,然后将其恢复为False
:
procedure TForm1.Button1Click(Sender: TObject);
var
Item: TListItem;
begin
Item := ListView1.Selected;
if Assigned(Item) then
begin
FCanEditListView := True;
Item.EditCaption;
FCanEditListView := False;
end;
end;
然后为OnEditing
列表视图的事件添加一个处理程序,以如下方式切换行为:
procedure TForm1.ListView1Editing(Sender: TObject; Item: TListItem;
var AllowEdit: Boolean);
begin
AllowEdit := FCanEditListView;
end;
于 2014-07-06T20:21:46.837 回答