Page 1 of 1

wxlistctrl控件时刻更新问题!

Posted: Mon Nov 16, 2009 2:39 am
by duangexin
在数据库操作中:插入数据时想让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.
请问这个怎么获取最后一行也就是行数,才能达到时刻更新呢?请知道的朋友指点一下。谢谢。

Posted: Tue Feb 23, 2010 3:37 am
by xin.songtao
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;
希望对于有些帮助。