wxListCtrl report style - how to fill all columns in row? 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
michalm
Earned some good credits
Earned some good credits
Posts: 122
Joined: Wed Dec 13, 2006 3:25 pm

wxListCtrl report style - how to fill all columns in row?

Post by michalm » Tue Jan 08, 2008 10:24 am

Hello,

I have wxListCtrl with report style and 3 column headers. I'm trying to add data, but there is a problem - how to set labels for all colums in one row?

Code: Select all

void listaDlg::ListAddItem(wxString nazwa, wxString data,wxString numer)

{

 wxListItem *tmpItem = new wxListItem();





 tmpItem->SetText(nazwa);

 tmpItem->SetColumn(0);

 tmpItem->SetId(0);

 listaList->InsertItem(*tmpItem);

 

 tmpItem->SetText(data);

 tmpItem->SetColumn(1);

 tmpItem->SetId(0);

 listaList->InsertItem(*tmpItem);

 

 tmpItem->SetText(numer);

 tmpItem->SetColumn(2);

 tmpItem->SetId(0);

 listaList->InsertItem(*tmpItem);

 

 delete tmpItem;

}    

ListAddItem("Test 1","Test 2","Test 3");

But Test 1 is first row and first col, Test 2 second row and second col, Test 3 third row and third col.

I want to Test 1, Test 2 and Test 3 in the same row, how to do this?

ddv
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Dec 18, 2006 4:23 pm

Post by ddv » Tue Jan 08, 2008 11:22 am

There is no predefined method for this.

Why not write a method in a wxListItem or wxListCtrl inherited class that takes a single string as parameter that accepts the separator '\t' (for example). You just have to parse the string.

Ex:
(MyListCtrl*)listaList->InsertItems(0, "Text1\tText2\tText3\tText4");

michalm
Earned some good credits
Earned some good credits
Posts: 122
Joined: Wed Dec 13, 2006 3:25 pm

Post by michalm » Tue Jan 08, 2008 12:28 pm

:shock: So report style is completely unusefull, because there are empty cells - I wonder that they can't be filled :?
Why not write a method in a wxListItem or wxListCtrl inherited class that takes a single string as parameter that accepts the separator '\t' (for example). You just have to parse the string.
How to do this? String parsing is not a problem. But every string is displayed in first column in report mode and - as you said above, there is no any method to access mulitple colums in the same row. So, how to display parsed "Test 2" string next to "Test 1", but below second column header (it also should move when column is resized)

I hope you know what I mean...

ddv
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Dec 18, 2006 4:23 pm

Post by ddv » Tue Jan 08, 2008 1:00 pm

Sorry I misunderstood your problem.

You make first a InsertItem to fill the 1st column. InsertItem then returns the index of the new item.
For each next column, you use wxListCtrl::SetItem

long idx = myList->InsertItem(0, "Text1");
myList->SetItem(idx, 1, "Text2");
myList->SetItem(idx, 2, "Text3");

michalm
Earned some good credits
Earned some good credits
Posts: 122
Joined: Wed Dec 13, 2006 3:25 pm

Post by michalm » Wed Jan 09, 2008 9:43 am

This should help - thanks fo response.

Post Reply