CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    68

    2 simple CListCtrl questions = )

    hi,

    actually, i have 2 questions.

    1. given an index of an item in a list control (CListCtrl ). how do i highlite it?

    i tried:

    lvitem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
    lvitem.state = LVIS_SELECTED | LVIS_FOCUSED;

    as in my code below

    lvitem.mask = LVIF_IMAGE | LVIF_TEXT;
    lvitem.iItem = m_cactions_list.GetItemCount();
    lvitem.iSubItem = 0;
    lvitem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
    lvitem.state = LVIS_SELECTED | LVIS_FOCUSED;

    //other item setup here...

    lvitem.pszText = key_hit;
    actions_list.InsertItem( &lvitem );

    i was thinking that it would set foucs/highlite to the last inserted item, but its not working.


    2. given an index of an item in a list. how can i move it up or down in the list, ie. change its index?


    thank you,
    jeremy


  2. #2
    Join Date
    Apr 1999
    Location
    Michigan, USA
    Posts
    115

    Re: 2 simple CListCtrl questions = )

    Well for one thing:
    vitem.mask = LVIF_IMAGE | LVIF_TEXT;
    will have to be changed to
    vitem.mask = LVIF_IMAGE | LVIF_TEXT|LVIF_STATE;
    otherwise vitem.state will pretty much be ignored.


  3. #3
    Guest

    Re: 2 simple CListCtrl questions = )

    1) Try changing "lvitem.iItem = m_cactions_list.GetItemCount()" to
    "lvitem.iItem = m_cactions_list.GetItemCount() - 1" since iItem is zero based.

    2) One of the articles in the Listview control section has a solution to this problem, but I do not remember which one it was.

    Lee



Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured