Solved

programmatically enable EDITLABLES in listControl

Posted on 1998-09-18
2
519 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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