Solved

programmatically enable EDITLABLES in listControl

Posted on 1998-09-18
2
500 Views
Last Modified: 2013-11-19
1)  I want to programmatically enable editing of current SELECTED/FOCUSED list item (in CListCntrl). How to do it (with input focus)?

2)  How to enable editing of a specific column within a row (in multi-column list control)?
-----

For example in AppWizrd when you create a list control (in a dialog) you can set a property flag ("Edit lable" check box) in property page.

I want to do it at run time programmatically. I tried the following, but is not working:

Failed method 1:
-------------------------
//begin in-place editing of the newly inserted row
CEdit * pEdit = m_ListCtrl.EditLabel( m_ListCtrl.GetItemCount( )  );
if (NULL != pEdit )
pEdit->SetFocus();

Failed method   2:
------------------------------
//Insert items
LV_ITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_STATE;
lvi.iItem = m_ListCtrl.GetItemCount( );
lvi.iSubItem = 0;
lvi.iImage = 0;
lvi.stateMask =  LVIS_CUT | LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED |  LVS_EDITLABELS | LVS_SHOWSELALWAYS ;
lvi.state = LVIS_FOCUSED | LVIS_SELECTED ;
       
lvi.pszText = "";
//insert this item now!            m_ListCtrl.InsertItem(&lvi);
//make this new item selected/in-focus
m_ListCtrl.SetItemState(m_ListCtrl.GetItemCount( ), LVIS_FOCUSED | LVIS_SELECTED, LVIS_SELECTED);
            UpdateData(FALSE);

//send begin lable edit message
m_ListCtrl.PostMessage(WM_NOTIFY, IDC_LISTCTRL, (LPARAM)&msgHdr);
//or this line!!!!!!!!!!!!!!!! (alternatively)            ::SendMessage(m_ListEmailUserNames.GetSafeHwnd(), LVN_BEGINLABELEDIT, IDC_LISTCTRL,  (LPARAM)&lvi);


0
Comment
Question by:dvenkat
2 Comments
 

Accepted Solution

by:
umarama earned 50 total points
Comment Utility
GetItemCount will always be one greater than the highest available item-index for the list ctrl !

Using that for item-index, hence, will never address any valid index !

I could edit my item by issuing EditLabel(correct index). In fact, try subclassing the edit control in OnBeginLabelEdit and the editing feature looks slick !

0
 

Author Comment

by:dvenkat
Comment Utility
Thanks for pointing out error in my program! It works fine now ( with EditLabel(correct index))

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now