怎样在 CClistCtrl 中改变某一个 Item 中的显示

sungengyu 2003-08-20 01:55:07
很简单的那种,就是单击 CClistCtrl中 的某一项,就可以改变(手工输入或者下拉选择)其中的显示。

最好能简单说明一下,因为我很菜 ^ ^

谢谢了

在线等待。
...全文
57 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
sungengyu 2003-08-21
  • 打赏
  • 举报
回复
上面 helloair(老婆,我只要十块钱) 的那段代码有问题,需要改一下才能用
但是总算让我明白了怎么做


:)
孤必有邻 2003-08-20
  • 打赏
  • 举报
回复
来得太晚了(结帐了才来)
sungengyu 2003-08-20
  • 打赏
  • 举报
回复
谢谢大家了:)
helloair 2003-08-20
  • 打赏
  • 举报
回复
还是看这个吧http://www.codeproject.com/listctrl/editing_subitems_in_listcontrol.asp
zhang1000 2003-08-20
  • 打赏
  • 举报
回复
自己建一个CEdit UpdateEdit;
双击时判断落在哪个单元格内(OnDblclkYourlist(NMHDR* pNMHDR, LRESULT* pResult))
显示编辑框...
取出原来单元格的内容显示在编辑框中....
修改完成后更新选中的单元格内容...
隐藏编辑框...
balas 2003-08-20
  • 打赏
  • 举报
回复
我一个做好的类
helloair 2003-08-20
  • 打赏
  • 举报
回复
添加OnClickListu()
void CUserDialog::OnClickListu(NMHDR* pNMHDR, LRESULT* pResult)
{
Invalidate();
HWND hWnd1 = ::GetDlgItem (m_hWnd,IDC_LISTU);//IDC_LISTU是CClistCtrl的ID
LPNMITEMACTIVATE temp = (LPNMITEMACTIVATE) pNMHDR;
RECT rect;
//get the row number
nItem = temp->iItem;
//get the column number
nSubItem = temp->iSubItem;
//Retrieve the text of the selected subItem
//from the list
CString str = GetItemText(hWnd1,nItem ,nSubItem);

RECT rect1,rect2;
// this macro is used to retrieve the Rectanle
// of the selected SubItem
ListView_GetSubItemRect(hWnd1,temp->iItem,
temp->iSubItem,LVIR_BOUNDS,&rect);
//Get the Rectange of the listControl
::GetWindowRect(temp->hdr.hwndFrom,&rect1);
//Get the Rectange of the Dialog
::GetWindowRect(m_hWnd,&rect2);

int x=rect1.left-rect2.left;
int y=rect1.top-rect2.top;
if(nItem != -1)
::SetWindowPos(::GetDlgItem(m_hWnd,IDC_EDITL),//IDC_EDITL是一个编辑框控件ID
HWND_TOP,rect.left+x+3,rect.top+14,
rect.right-rect.left - 3,
rect.bottom-rect.top -1,NULL);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDITL),SW_SHOW);
::SetFocus(::GetDlgItem(m_hWnd,IDC_EDITL));
//Draw a Rectangle around the SubItem
::Rectangle(::GetDC(temp->hdr.hwndFrom),
rect.left,rect.top-4,rect.right,rect.bottom);
//Set the listItem text in the EditBox
::SetWindowText(::GetDlgItem(m_hWnd,IDC_EDITL),str);
*pResult = 0;
}
sungengyu 2003-08-20
  • 打赏
  • 举报
回复
好像选择了Edit Labels之后也只能修改第一列中的,我想点击随便哪一个都可以。
还有 …… 修改之后怎么保存?

如果要下拉框,怎么做啊?


麻烦你了:)
bluestar 2003-08-20
  • 打赏
  • 举报
回复
在控件的Styles里选择Edit Labels,点击某一项可以成为编辑框

如果要下拉框,就要自己做了。

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧