tags:

views:

1554

answers:

2

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

A: 

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.

Aidan Ryan
+1  A: 

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.

jussij