如果没有代码,请问如何实现,谢谢

解决方案 »

  1.   

    不用发,原理基本都是这样:创建一个隐藏的edit,当你在某个格子里点击时,把edit movewindow到那里然后显示出来,并将那个格子的内容copy到edit,edit失去焦点后,把edit内容copy回来,隐藏edit....
      

  2.   

    http://www.codeproject.com/KB/list/   在这里面找找
      

  3.   

    参看潘爱民的<VC++6.0技术内幕>第4版,网上有电子文档下,其中有具体实例.
      

  4.   

    到CodeProject,codeguru上面找找,很多的。
    要不,你留个邮箱,我给你发过去几个。
      

  5.   

    grid也是不可编辑的  好像是 忘了
    网上有第三方类ClistControl 写好的  原理1楼所说  编辑时焦点置在要编辑的地方 创建的eidt控件置在上面 编辑完成 LIST中被替换  
      

  6.   

    参考codeproject上的,加下面3个接口
    void CShowAllProcessDlg::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) 
    { // TODO: Add your control notification handler code here
        Invalidate();
        HWND hWnd1 =  ::GetDlgItem (m_hWnd,IDC_LIST1);
        LPNMITEMACTIVATE temp = (LPNMITEMACTIVATE) pNMHDR;
        RECT rect;
        //get the row number
        nItem = temp->iItem;
        //get the column number
        nSubItem = temp->iSubItem;
        if(nSubItem == 0 || nSubItem == -1 || nItem == -1)
            return ;
        //Retrieve the text of the selected subItem 
        //from the list
        CString str = m_showlist.GetItemText(nItem ,
            nSubItem);    RECT rect1,rect2;
        // this macro is used to retrieve the Rectangle 
        // of the selected SubItem
        ListView_GetSubItemRect(hWnd1,temp->iItem+1,
            temp->iSubItem,LVIR_BOUNDS,&rect);
        //Get the Rectangle of the listControl
        ::GetWindowRect(temp->hdr.hwndFrom,&rect1);
        //Get the Rectangle 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_EDIT1),
            HWND_TOP,rect.left+x,rect.top-1, 
            rect.right-rect.left+2,
            rect.bottom-rect.top+2,NULL);
        ::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT1),SW_SHOW);
        ::SetFocus(::GetDlgItem(m_hWnd,IDC_EDIT1));
        //Draw a Rectangle around the SubItem
    //   ::Rectangle(::GetDC(temp->hdr.hwndFrom),rect.left,rect.top,rect.right,rect.bottom);
       
        //Set the listItem text in the EditBox
        ::SetWindowText(::GetDlgItem(m_hWnd,IDC_EDIT1),str);
        *pResult = 0;
    }void CShowAllProcessDlg::OnOK()
    {
    CWnd* pwndCtrl = GetFocus();
        // get the control ID which is 
        // presently having the focus
        int ctrl_ID = pwndCtrl->GetDlgCtrlID();
        CString str;
    m_showlist.GetItemText(nItem ,nSubItem);
        switch (ctrl_ID)
        {   //if the control is the EditBox 
    case IDC_EDIT1:
            //get the text from the EditBox
            GetDlgItemText(IDC_EDIT1,str);

            //set the value in the listContorl with the
            //specified Item & SubItem values
            SetCell(::GetDlgItem (m_hWnd,IDC_LIST1),
                str,nItem,nSubItem);
            ::SendDlgItemMessage(m_hWnd,IDC_EDIT1,
                WM_KILLFOCUS,0,0);
            ::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT1),
                SW_HIDE);
    break;     
    default:
    break;
        }

    }void CShowAllProcessDlg::SetCell(HWND hWnd1, CString Value, int nRow, int nCol)
    {
    TCHAR     szString [256];
        wsprintf(szString,Value ,0);    //Fill the LVITEM structure with the 
        //values given as parameters.
        LVITEM lvItem;
        lvItem.mask = LVIF_TEXT;
        lvItem.iItem = nRow;
        lvItem.pszText = szString;
        lvItem.iSubItem = nCol;
        if(nCol >0)
            //set the value of listItem
            ::SendMessage(hWnd1,LVM_SETITEM, 
                (WPARAM)0,(WPARAM)&lvItem);
        else
            //Insert the value into List
            ListView_InsertItem(hWnd1,&lvItem);
        //m_showlist.SetItemText(nRow,nCol,Value);}
      

  7.   

    这里有个List Control示例 http://tech.ddvip.com/2006-04/11441788803666.html
    讲得详细。代码也可以下载。可以去看看
      

  8.   

    Quote=引用 1 楼 hurryboylqs 的回复:]
    不用发,原理基本都是这样:创建一个隐藏的edit,当你在某个格子里点击时,把edit movewindow到那里然后显示出来,并将那个格子的内容copy到edit,edit失去焦点后,把edit内容copy回来,隐藏edit....
    [/Quote]
      

  9.   

    呵呵 这几天没有上来 楼主如果还需要的话给我发个邮件[email protected]
      

  10.   

    http://www.codeproject.com/KB/list/editing_subitems_in_listcontrol.aspx