当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Trigger the ObjectListView cell into editing status from outside

问题描述:

We have a win form, there is an ObjectListView and a button named btnOK on the form. Normally, I can edit a cell by click on the cell in the ObjectListView but I want the specify cell go into the editing status (a TextBox in the cell and focus on it) by clicking the btnOK.

It seems that ObjectListView does not support it, as the CellEventArgs only provide the properties which support "get" method only, but not provide "set" method.

Is there any possible or any other way to implement my requirement?

网友答案:

It seems that ObjectListView does not support it, as the CellEventArgs only provide the properties which support "get" method only, but not provide "set" method.

Because CellEventArgs contains arguments for an ObjectListView event (for example CellEditFinishing), triggered in response to something that did happen. What you need to do is to programmatically start something that will happen.

But I want the specify cell go into the editing status (a textbox in the cell and focuse on it) by click the btnOK.

Simply call ObjectListView.EditSubItem() method. First parameter is a reference to list item you want to edit and second parameter which sub-item (column...) you want to edit. For example to start editing currently focused item:

ctrlList.EditSubItem((OLVListItem)ctrlList.FocusedItem, 0);
分享给朋友:
您可能感兴趣的文章:
随机阅读: