subject_17981.htm
来自「一些关于vc的问答」· HTM 代码 · 共 36 行
HTM
36 行
<p>
序号:17981 发表者:方舟 发表日期:2002-10-17 09:16:55
<br>主题:CListCtrl控件的问题
<br>内容: for(int nListEntry=0;!m_setComplete.IsEOF();nListEntry++)<BR> {<BR> m_lcRepeaterList.InsertItem(nListEntry,LPCTSTR(itoa(m_setComplete.m_iId,szBuffer,10)),0);<BR><BR> m_lcRepeaterList.SetItemText(nListEntry,1,LPCTSTR(m_setComplete.m_strFrequency));<BR><BR> m_lcRepeaterList.SetItemText(nListEntry,2,LPCTSTR(m_setComplete.m_strCallsign));<BR><BR> m_lcRepeaterList.SetItemText(nListEntry,3,LPCTSTR(m_setComplete.m_strInput));<BR><BR> m_lcRepeaterList.SetItemText(nListEntry,4,LPCTSTR(m_setComplete.m_strCity));<BR> <BR> m_lcRepeaterList.SetItemText(nListEntry,5,LPCTSTR(m_setComplete.m_strState));<BR><BR> m_setComplete.MoveNext();<BR> }<BR><BR>为何我的ClistCtrl控件种只显示插入的m_iId而后边的都不显示呀???<BR>BOOL SetItemText( int nItem, int nSubItem, LPTSTR lpszText )nItem指的是何?nSubItem指的是何?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:CDMA2000 回复日期:2002-10-17 09:25:11
<br>内容:nItem指的是插入的行的位置索引<BR>nSubItem指的是某行的列的位置索引
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小戟 回复日期:2002-10-17 09:31:29
<br>内容:是不是没有添加列呀!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:CDMA2000 回复日期:2002-10-17 09:32:12
<br>内容:后边的都不显示,是不是因为你在InsertColumn<BR>时没有插入足够的列头啊
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:徐景周 回复日期:2002-10-17 10:07:58
<br>内容:将你的SetItemText中的列改用GetItemCount用循环实现,如下:<BR><BR>extern CListCtrl* pmyListCtrl;<BR><BR>CString strText;<BR>int nColumnCount = pmyListCtrl->GetHeaderCtrl()->GetItemCount();<BR><BR>// Insert 10 items in the list view control.<BR>for (int i=0;i < 10;i++)<BR>{<BR> strText.Format(TEXT("item %d"), i);<BR><BR> // Insert the item, select every other item.<BR> pmyListCtrl->InsertItem(<BR> LVIF_TEXT|LVIF_STATE, i, strText, <BR> (i%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED,<BR> 0, 0);<BR><BR> // Initialize the text of the subitems.<BR> for (int j=1;j < nColumnCount;j++)<BR> {<BR> strText.Format(TEXT("sub-item %d %d"), i, j);<BR> pmyListCtrl->SetItemText(i, j, strText);<BR> }<BR>}<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:beastbird 回复日期:2003-04-22 00:11:59
<br>内容:不要从MSDN上面随便抄一端就来糊弄人,按照这种方法是可以,但是还是不能解决问题。<BR>我在其他地方看见是在插入后,在从0(记住不是从一)开始,重新用SetItemText()插入数据。<BR>不知道是否可行,希望可以!!<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?