如何使用 CListCtrl 就地编辑列?
我希望 CListCtrl.EditLabel() 用于列表的任何列.如何实现这样的功能?
I want to have CListCtrl.EditLabel() for any column of the list. How can I implement such a feature?
推荐答案
这是可行的,但它确实需要大量的鼠标点击和焦点事件.
This is doable but it does require a fair bit of stuffing around with mouse clicks and focus events.
简而言之,您捕获鼠标左键按下消息并将其转换为单元格点击详细信息(即行和列索引).
In a nutshell you trap the left mouse button down message and convert it into a cell hit details (i.e a row and column index).
使用这些单元格详细信息,您无法确定列表视图单元格的大小和位置以及其中包含的文本值.
With these cell details you can not determine the size and location of the list view cell and also the text value that it contains.
现在使用上一步中的大小和位置详细信息直接在此单元格上创建一个 CEdit 控件,并为其提供单元格的文本值.
Now create a CEdit control directly over this cell by using size and location details from the previous step and give it the text value of the cell.
最后一步是处理 CEdit 的焦点和键盘输入事件,以便可以将 CEdit 的文本详细信息放回列表视图单元格中.
The final step is to handle the focus and keyboard enter events for the CEdit so that the text details of the CEdit can be put back into the list view cell.
它确实需要大量的编码,但如果处理得当,它确实可以很好地替代网格控件.
It does take a fair amount of coding but when done right it does work well as an alternative to a grid control.
相关文章