wxlistctrl控件时刻更新问题!

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
Post Reply
duangexin
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Oct 30, 2009 12:46 am

wxlistctrl控件时刻更新问题!

Post by duangexin » Mon Nov 16, 2009 2:39 am

在数据库操作中:插入数据时想让wxlistctrl控件随着时刻更新,在VC中

Code: Select all

m_listCtrl1.DeleteAllItems();
m_listCtrl1->SetRedraw(false);
while (m_listCtrl1->DeleteColumn(0));
最后插入之后

Code: Select all

m_listCtrl1->SetRedraw(true);
我查看了wxlistctl的属性中有RefreshItems
wxListCtrl::RefreshItems
void RefreshItems(long itemFrom, long itemTo)
Redraws the items between itemFrom and itemTo. The starting item must be less than or equal to the ending one.
请问这个怎么获取最后一行也就是行数,才能达到时刻更新呢?请知道的朋友指点一下。谢谢。

xin.songtao
Experienced Solver
Experienced Solver
Posts: 86
Joined: Wed Apr 18, 2007 6:10 am
Location: Shanghai China

Post by xin.songtao » Tue Feb 23, 2010 3:37 am

wxListCtrl::InsertItem
Inserts an item, returning the index of the new item if successful, -1 otherwise.
插入的时候会得到一个index。
删除的时候也可以得到最后的位置。

Code: Select all

		long lastPos = 0;
		wxArrayInt DelIndex;		
		int nDeleteNum = 0;
		long item = -1;

		for(;;)
		{
			item =  m_pListCtrl->GetNextItem(item,wxLIST_NEXT_ALL,wxLIST_STATE_SELECTED);//next item;
			if (item==-1)
			{
				break;
			}
			DelIndex.push_back(item);				
		}

		for (int i = 0; i < selItemCount; i++)
		{
			m_pListCtrl->DeleteItem(DelIndex.Item(i)-nDeleteNum);
			nDeleteNum++;
			lastPos = DelIndex.Item(i)-nDeleteNum+1;
		}		
		
		if (lastPos>m_pListCtrl->GetItemCount()-1)
			lastPos=0;
希望对于有些帮助。
from: Shanghai China
language: C++/C
platform:MSW\MacOS\Linux
Email: [email protected]

Post Reply