How to edit columns in-place with CListCtrl?(如何使用 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.
这篇关于如何使用 CListCtrl 就地编辑列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 CListCtrl 就地编辑列?
基础教程推荐
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 初始化列表*参数*评估顺序 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
