how can I use wxDataViewItemArray? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
luna80
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Apr 05, 2021 6:53 am

how can I use wxDataViewItemArray?

Post by luna80 »

I don't understand how to use wxDataViewItemArray

I want to get this code works...

Code: Select all

...
lstProduzioni = new wxDataViewListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, xDV_MULTIPLE|wxDV_ROW_LINES|wxDV_HORIZ_RULES);
......
void ReportSettProduzioniDialog::OnClickLst(wxDataViewEvent& event)
{
	wxDataViewItemArray arrSel;
	lstProduzioni->GetSelections(arrSel);
	for (int i = 0; i < (int)arrSel.size(); i++)
	{
		cout << i << ")" <<  lstProduzioni->GetTextValue(arrSel[i], 0) << endl;
	}
}	
In this way I get this error
error: invalid user-defined conversion from ‘_wxArraywxDataViewItemArray’ {aka ‘wxDataViewItem’} to ‘unsigned int’ [-fpermissive]
132 | cout << i << ")" << lstProduzioni->GetTextValue(arrSel, 0) << endl;
| ^


can somebody help me please? thanks in advance
User avatar
luna80
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Apr 05, 2021 6:53 am

Re: how can I use wxDataViewItemArray?

Post by luna80 »

I found a solution , in case that somebody has the same problem I solved so

Code: Select all

void ReportSettProduzioniDialog::OnClickLst(wxDataViewEvent& event)
{
	int itemCount = lstProduzioni->GetSelectedItemsCount();
	wxDataViewItemArray arrSel;
	lstProduzioni->GetSelections(arrSel);
	produzioniSel->clear();
	for(int i = 0; i < itemCount; ++i) 
	{
		int row = lstProduzioni->ItemToRow(arrSel[i]);
		cout << i << ")" <<  lstProduzioni->GetTextValue(row, 0) << endl;
	}
}
Post Reply