如何使用 CListCtrl 就地编辑列?

发布于 2024-07-08 09:11:47 字数 57 浏览 8 评论 0原文

我希望列表的任何列都有 CListCtrl.EditLabel() 。 我怎样才能实现这样的功能?

I want to have CListCtrl.EditLabel() for any column of the list. How can I implement such a feature?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝對不後悔。 2024-07-15 09:11:47

这是可行的,但它确实需要大量的鼠标点击和焦点事件填充。

简而言之,您捕获鼠标左键按下消息并将其转换为单元格命中详细信息(即行和列索引)。

通过这些单元格详细信息,您无法确定列表视图单元格的大小和位置以及它包含的文本值。

现在,使用上一步中的大小和位置详细信息直接在此单元格上创建一个 CEdit 控件,并为其指定单元格的文本值。

最后一步是处理 CEdit 的焦点和键盘输入事件,以便可以将 CEdit 的文本详细信息放回到列表视图单元格中。

它确实需要大量的编码,但如果做得正确,它确实可以很好地作为网格控件的替代品。

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.

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.

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.

爱要勇敢去追 2024-07-15 09:11:47

不要尝试使用 CListCtrl。

使用 MFC 网格控件。 我们成功地将其部署在现成的应用程序中。 它为所有单元格提供就地编辑、复选框、旋转等,以及列标题和行标题、自动调整大小、自动扩展、颜色、拖放。

Don't attempt with CListCtrl.

Use the MFC Grid Control. We deploy it in an off-the-shelf app with success. It offers in-place edit, checkbox, spin, etc for all cells, as well as column and row headers, auto-size, auto-expand, colors, drag-drop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文