Implementation of Tab key on list view
Hi all,
I have a list view created using resource editor,I set Extended style such as LVS_EX_GRIDLINES & LVS_EX_FULLROWSELECT,So my List view looking like a spread sheet.Editing of cell done by Double clicking event,Now I want to add Tab feature(Switching Focus from one cell to next.)Is there any winAPI is there for Tab feature.I tryed to capture VK_TAB under LVN_KEYDOWN,But i am not reciving any notification for that event
Re: Implementation of Tab key on list view
IMHO, TAB key is translated to movint to the next control in the parent.
Try to subclass the list control and handle WM_GETDLGCODE message
Re: Implementation of Tab key on list view
A listview (SysListView32) control having LVS_REPORT and LVS_EX_GRIDLINES styles may look like a spreadsheet/grid control but actually it's NOT.
By default, it doesn't allow selecting/editing a particular "cell" as you probably expect. Setting the LVS_EDITLABELS style, allows only editing of the "cells" in the first column.
However, you can resolve that issue either by customizing the behavior of the default "in-place" edit control or using your own in-place edit.
In both cases, if you want to change the behavior when the user presses the TAB key, as well as Enter and arrow keys, you have (as Victor already suggested) to basically:
- subclass the in-place edit control (that means, replace the default edit's window procecure with an application-defined one);
- handle WM_GETDLGCODE and return DLGC_WANTTAB (or other value if you want something else);
- handle WM_KEYDOWN message and change the default behavior as your muscles want (e.g. move the in-place edit over another "cell").
How to exactly make an editable (cell by cell) listview control is a long story, especially if you are using just raw-WinAPI (no MFC, no anything else that can make your programmer's life easier).