Click to See Complete Forum and Search --> : Tree control - How to edit label?


manjaly
May 26th, 1999, 10:30 PM
I have problems with editing label of a tree control item. I am getting the the new label only if I type some new characters. If I just leave the old characters as it is, I am getting only a NULL string in OnEndlabeleditTree(). Do somebody have a solution for this?
Thanks,
Tony

YunFeiLi
May 26th, 1999, 10:37 PM
If you leave the old characters as it is,the edit cotrol will send a NULL string to the tree control,so you must overide the CTreeCtrl::OnEndlabeledit(...)just lik this:

void CMyTreeCtrl::OnEndlabeledit(NUMHDR *pNMHDR,LRESULT *pResult)
{
TV_DISPINFO *pTVDispInfo=(TV_DISPINFO*)pNMHDR;
CString strItem=pTVDispInfo->item.pszText;
if(!strItem.IsEmpth())//if the string is //empty,do nothing!
{
SetItemText(pTVDispInfo- >item.hItem,strItem);
}
}