ListCTRL in Report-Mode - Get text of second or third column 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
Morfio
Experienced Solver
Experienced Solver
Posts: 70
Joined: Thu Jul 07, 2005 4:35 pm

ListCTRL in Report-Mode - Get text of second or third column

Post by Morfio »

Hi,

on doubleclicking a row in a listctrl I want to get the strings of all columns. After reading the docs and the examples I've no idea how to do this.

It's no problem to get the first column. I'd created an event (EVT_LIST_ITEM_ACTIVATED). But how can I get the other columns?

Thank you,

Morfio ...
Last edited by Morfio on Thu Sep 01, 2005 12:31 pm, edited 1 time in total.
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Use wxListCtrl::GetItem() and in the wxListItem set the column and ID first.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
Morfio
Experienced Solver
Experienced Solver
Posts: 70
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio »

It doesn't work, here is my code:

Code: Select all

void VAddress::editBank(wxListEvent &event) {
	wxListItem bank = event.GetItem();
	
	bank.SetId(0);
	bank.SetColumn(2);
	
	cbLiquiditaetBank->SetValue(bank.GetText());
}
I want to get the third column, but I get always the first.
Morfio
Experienced Solver
Experienced Solver
Posts: 70
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio »

As I see in the wiki is a tutorial. I just try this out.
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Morfio wrote:It doesn't work, here is my code:

Code: Select all

void VAddress::editBank(wxListEvent &event) {
	wxListItem bank = event.GetItem();
	
	bank.SetId(0);
	bank.SetColumn(2);
	
	cbLiquiditaetBank->SetValue(bank.GetText());
}
I want to get the third column, but I get always the first.
True as the event only contains the first column. What I meant was:

Code: Select all

void VAddress::editBank(wxListEvent &event) {
	wxListItem bank = event.GetItem();
	
	bank.SetColumn(2);
	myListCtrl->GetItem(bank);
	cbLiquiditaetBank->SetValue(bank.GetText());
}
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
Morfio
Experienced Solver
Experienced Solver
Posts: 70
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio »

No it works fine. Thank you very much :D
Morfio
Experienced Solver
Experienced Solver
Posts: 70
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio »

Now I've got an other problem. If I only want to get one column, it works realy fine. But if I want to get the next, I always get the same text:

Code: Select all

void VAddress::editBank(wxListEvent &event) {
	cbLiquiditaetBank->SetValue(event.GetText());

	wxListItem bank = event.GetItem();
	bank.SetId(event.GetId());
	
	bank.SetColumn(1);
	lcLiquiditaetBanken->GetItem(bank);
	tcLiquiditaetBlz->SetValue(bank.GetText());

	bank.SetColumn(2);
	lcLiquiditaetBanken->GetItem(bank);
	tcLiquiditaetKontonummer->SetValue(bank.GetText());

	...
}
If I create an new object (wxListItem) for the second column it doesn't work, too.
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Did you try setting the ID in both cases?
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
Morfio
Experienced Solver
Experienced Solver
Posts: 70
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio »

Yes:

Code: Select all

void VAddress::editBank(wxListEvent &event) {
	cbLiquiditaetBank->SetValue(event.GetText());

	wxListItem bank = event.GetItem();

	bank.SetId(event.GetId());
	bank.SetColumn(1);
	lcLiquiditaetBanken->GetItem(bank);
	tcLiquiditaetBlz->SetValue(bank.GetText());

	bank.SetId(event.GetId());
	bank.SetColumn(2);
	lcLiquiditaetBanken->GetItem(bank);
	tcLiquiditaetKontonummer->SetValue(bank.GetText());
}
vasek
Experienced Solver
Experienced Solver
Posts: 77
Joined: Wed Jul 27, 2005 2:52 pm
Location: Ostrava, Czech Republic
Contact:

Post by vasek »

This works good for me:

Code: Select all

wxListItem i;
i.SetMask(wxLIST_MASK_TEXT);
i.SetId(item);

i.SetColumn(1);
listConnections->GetItem(i);
address->SetValue(i.GetText());

i.SetColumn(2);
listConnections->GetItem(i);
port->SetValue(i.GetText());
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Right, SetMask... Sorry I forgot about that :D
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
Morfio
Experienced Solver
Experienced Solver
Posts: 70
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio »

Now this works pretty good. Thank you all!

Code: Select all

void VAddress::editBank(wxListEvent &event) {
	wxListItem bank;
	bank.SetMask(wxLIST_MASK_TEXT); 
	bank.SetId(event.GetIndex());

	bank.SetColumn(0);
	lcLiquiditaetBanken	->GetItem(bank);
	cbLiquiditaetBank->SetValue(bank.GetText());

	bank.SetColumn(1);
	lcLiquiditaetBanken->GetItem(bank);
	tcLiquiditaetBlz->SetValue(bank.GetText());

	bank.SetColumn(2);
	lcLiquiditaetBanken->GetItem(bank);
	tcLiquiditaetKontonummer->SetValue(bank.GetText());
}
Post Reply