Solved

programmatically enable EDITLABLES in listControl

Posted on 1998-09-18
2
513 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
ID: 1322315
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
ID: 1322316
Thanks for pointing out error in my program! It works fine now ( with EditLabel(correct index))

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 152
Host to IP 7 82
substring method in java 1 135
conditional code and condition difference 9 84
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

680 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