我输入了一行数据进列表了,请问我怎么将他们保存在一个地方。
我用GetItemText()发现还是空的

解决方案 »

  1.   


    有。我把我的函数代码给你看下
    void CComboListCtrl::OnLstInsert() 
    {
    // TODO: Add your command handler code here
    CString strResource;
    strResource.Format( _T("输入变量名 ")); int iCount = GetItemCount(); int iRow = -1; POSITION SelectedItemPos =GetFirstSelectedItemPosition();
    int iIndex = -1;
    int iLastSelectedIndex = -1; while (SelectedItemPos)
    {
    iIndex = GetNextSelectedItem(SelectedItemPos); if ((LVIS_SELECTED == GetItemState(iIndex, LVIS_SELECTED)) && 
    (LVIS_FOCUSED == GetItemState(iIndex, LVIS_FOCUSED)))
    {
    iRow = iIndex;
    }
        SetItemState(iIndex, 0, LVIS_SELECTED|LVIS_FOCUSED);
    } if (-1 == iRow)
    {
    InsertItem(LVIF_TEXT|LVIF_STATE, iCount, 
    strResource, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED, 0, 0);
    }
    else
    {
    InsertItem(LVIF_TEXT|LVIF_STATE, iRow, 
    strResource, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED, 0, 0);
    }
    UpdateData(FALSE);
    CString str=GetItemText(iCount,0);        //未变化(仍为“输入变量名”)
    CString str1=GetItemText(iCount,1);       //未变化(为空
    AddVar(GetItemText(iCount,0),GetItemText(iCount,1),"用户自定义变量");
    }谢谢
      

  2.   


    我的就是REPORT的dwStyle = WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT|LVS_EDITLABELS|LVS_SHOWSELALWAYS
     |LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_TABSTOP; 
      

  3.   

    你的另一贴解决了没有?
    //GetSelectionMark 这个函数用于获取你点击的那一行比较简单点
    int row=m_list.GetSelectionMark (); //这样可以获取你点击的那一行,
    CString item=m_list.GetItemText(row,1);//这样可以获取你想要的单元格,col为第几列 
      

  4.   

    LRESULT CVariab::OnEndLabelEditVariableCriteria(WPARAM wParam, LPARAM lParam) 
    {
    LV_DISPINFO* pDispInfo = (LV_DISPINFO*)lParam;
    // TODO: Add your control notification handler code here

    if (wParam == ID_LIST)
    {
    // Update the item text with the new text
    CString strUpdatedTxt = pDispInfo->item.pszText;  

    // Validate the format of the new string for the edit columns
    // If invalid then
    // Set pResult to 1 
    switch(pDispInfo->item.iSubItem)
    {
    case 0:
    case 1:
    break;
    default:
    {
    if (!strUpdatedTxt.IsEmpty()) 
           {
    //int iFirstNumeralOccurrance = strUpdatedTxt.FindOneOf("0123456789.");  //本来是第二列只能是数字的
    CString strNonNumerals = strUpdatedTxt.Left(iFirstNumeralOccurrance);
    CString strNumerals = strUpdatedTxt.Mid(iFirstNumeralOccurrance);

    strNonNumerals.TrimLeft(); 
    strNonNumerals.TrimRight();
    strNumerals.TrimLeft();
    strNumerals.TrimRight();   int iDecimalIndex = strNumerals.Find(".");

    if ((-1 != iDecimalIndex) && (iDecimalIndex != (strNumerals.GetLength() - 1)))  
    {
    iDecimalIndex = strNumerals.Find(".", iDecimalIndex + 1);
    }
    if (
    (!strNonNumerals.IsEmpty()) || 
    (-1 != strNumerals.Find(" ")) ||
    (-1 != iDecimalIndex)
       )
           {
    // AfxMessageBox("Invalid text entered. The text will be reset"); 
    // m_List.SetItemText(pDispInfo->item.iItem, pDispInfo->item.iSubItem, " ");
           }
    return 0;
         }
    }
    break;
    }
      } return 1;
    }
    这是我在单元格填充后的响应函数,和我同学一起做的结果.感觉错了,请大侠根据我这段代码和上面的代码,看看给出建议,谢谢了啊
      

  5.   

    CString str1=GetItemText(iCount,1);      //未变化(为空 你设置这列的数据了?没看到。