CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Implementation of Tab key on list view

  1. #1
    Join Date
    Apr 2013

    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

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Hanover Germany

    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
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2003
    Iasi - Romania

    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).
    Last edited by ovidiucucu; August 24th, 2013 at 04:15 AM.
    "When in Rome, do as Romans do."
    My latest articles: http://codexpert.ro/blog/author/ovidiu-cucu/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)