Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

programmatically enable EDITLABLES in listControl

Posted on 1998-09-18
2
Medium Priority
?
539 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
umarama earned 150 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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