Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Getting data in a row of ArrCtrl
Getting data in a row of ArrCtrl [message #2194] Mon, 03 April 2006 21:22 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Dear U++ Mate,

here I am with another question to waste your time and test your patience limit Smile.

The subject of this thread seems not yet discussed although very important. In fact the arrayctrl is one of the best widget available around (I left my old C GUI tool for it).

The problem: I have a beatiful arrayctrl (of course with my lovely colored even row) full of data. I need to get all the data contained on the clicked row. I found this information:

Vector<Value> ReadRow(int i) const

and when the strange sign '<...>' appeared everything became dark Smile . Does anybody know how to retrieve the data in the row?

Another observation: I tried the code

arr.NoDuplicating();

I believed it could prevent a new row equal to one already present in the array. I added 10 identical rows and nothing happened. Is it correct?

Thank you,
Luigi
Re: Getting data in a row of ArrCtrl [message #2196 is a reply to message #2194] Mon, 03 April 2006 21:42 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
forlano wrote on Mon, 03 April 2006 20:22

Does anybody know how to retrieve the data in the row?


1. When? (then think about when... Smile)
2. In what format and destination? - what do you want to do with the data?
Re: Getting data in a row of ArrCtrl [message #2197 is a reply to message #2196] Mon, 03 April 2006 22:05 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
fudadmin wrote on Mon, 03 April 2006 20:42

forlano wrote on Mon, 03 April 2006 20:22

Does anybody know how to retrieve the data in the row?


1. When? (then think about when... Smile)
2. In what format and destination? - what do you want to do with the data?


Also, this might be useful:
...
String s;
int row=0, col=0;
s=arr.ReadRow(row)[col]);  
Re: Getting data in a row of ArrCtrl [message #2198 is a reply to message #2197] Mon, 03 April 2006 22:39 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
also, you can play with this:
void Tab1::PromptCell(){
	String s;
	s=AsString(arr.ReadRow(arr.GetCursor())[arr.GetClickColumn()]);	
	PromptOK(s);
}

it is better to use AsString than in previous post because without it, you get crashes in some cases ... Smile
also, don't forget a useful method ToString() ...
Re: Getting data in a row of ArrCtrl [message #2200 is a reply to message #2198] Mon, 03 April 2006 23:19 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
or you can prepare your own database format with something like this:

	String s;
	int int_row = arr.GetCursor();
	for (int i=0; i<arr.GetColumnCount(); i++) {
		s << arr.Get(int_row, i);
		s << ":::";
      }

[Updated on: Mon, 03 April 2006 23:20]

Report message to a moderator

Re: Getting data in a row of ArrCtrl [message #2206 is a reply to message #2200] Tue, 04 April 2006 00:40 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
I have got so many answers that I am a bit confused Smile
I need to experiment each of them separately.

Please let me answer.

Quote:


1. When? (then think about when... )
2. In what format and destination? - what do you want to do with the data?



1. In principle when I click on a row I would like to have the possibility to retrieve the data (to send them in the above mask for some modification for example).
But after your question I think could be very useful to get the data even when I press some button (I need it for another Tab page). In this case I could want get the data where the cursor is and/or in corrispondence of a given row (think about a loop that scan all the rows).

2. Format? some of the cells (coloumns) in the row are string, other are integer. It is preferible to get them in their original format. But if all are retrieved as string it is perfect too.
Once the data are available I could send them in some other widget or save in a file... it depends. For the moment just pass to another widget.

Now please let me ask you something about your previous suggestion:

a)
void Tab1::PromptCell(){
	String s;
	s=AsString(arr.ReadRow(arr.GetCursor())[arr.GetClickColumn()]);	
	PromptOK(s);
}


I've associated this method to left_click event with

arr.WhenLeftClick = THISBACK(PromptCell);

Did you mean to play in this way?

Quote:


also, don't forget a useful method ToString() ...



What do you mean? Why I need this method (sorry for this silly question).

b)
	String s;
	int int_row = arr.GetCursor();
	for (int i=0; i<arr.GetColumnCount(); i++) {
		s << arr.Get(int_row, i);
		s << ":::";
      }


If I have understood, in this last example all the cells finish in 's' separated by ":::". Is this correct? It is evident that the operator '<<' does a continues strcat(...), it isn't. (Sometimes I feel to be a dinosaur... but I'm enjoing the short and powerfull syntax of C++ Smile ).

Luigi
Re: Getting data in a row of ArrCtrl [message #2207 is a reply to message #2194] Tue, 04 April 2006 01:08 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
forlano wrote on Mon, 03 April 2006 20:22

Dear U++ Mate,

1. here I am with another question to waste your time and test your patience limit Smile.
...

2. Vector<Value> ReadRow(int i) const

and when the strange sign '<...>' appeared everything became dark Smile . Does anybody know how to retrieve the data in the row?

...
3. Another observation: I tried the code

arr.NoDuplicating();

I believed it could prevent a new row equal to one already present in the array. I added 10 identical rows and nothing happened. Is it correct?

Thank you,
Luigi



1. if it's about me, and if you want to reach my patience limit you should post, I think, more than 50 messages per day... So, it's plenty of room... Smile Quite opposite, I'm not happy when you are progressing not fast enough... Smile Also, having in mind, that from the beginning of May till late Autumn, I guess, my visits here will be much more limited. So, use the chance... Smile

2. Don't worry about the signs <...>. Learn like a woman to drive a car... How many of them can drive but are completely lost if they look at the engine... Smile You have seen how easy was to make use of the designer... Smile And ask questions like this :
Quote:

how to retrieve the data from the array row?

Or try to formulate even better.
In fact, in most cases, proper formulation of your questions quite often suggests half the answer, if not the whole.
People, who can't properly formulate their questions, first of all, limit their learning speed, and second, limit their chances to recieve the proper answers quickly.

3. arr.NoDuplicating(); -if anything doesn't work, you should always look at the sources first. (in this case ArrayCtrl.h and ArrayCtrl.cpp.)
And to get there quickly use Alt_J and Alt_I !!! For me these are the most useful shortcuts in the whole U++!!! Learn them (be prepared for surprises...Smile)!!! Just don't forget to put editor's cursor inside the word!
Re: Getting data in a row of ArrCtrl [message #2208 is a reply to message #2206] Tue, 04 April 2006 01:34 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Quote:

1. In principle when I click on a row I would like to have the possibility to retrieve the data (to send them in the above mask for some modification for example).

You should have started with this question ... without the word retrieve Smile
Or maybe better - how to fill the edit fields when cursor moves along the rows?

Btw, there is an easy possibility to edit cells directly in the ArrayCtrl like in spreadsheets... Maybe it's better to use those edit fields only just for searching. Just an idea...

Btw, why don't you want to use xml format?
Re: Getting data in a row of ArrCtrl [message #2209 is a reply to message #2206] Tue, 04 April 2006 01:46 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
forlano wrote on Mon, 03 April 2006 23:40



2. Format? some of the cells (coloumns) in the row are string, other are integer.

Quote:


also, don't forget a useful method ToString() ...



What do you mean? Why I need this method (sorry for this silly question).

b)
	String s;
	int int_row = arr.GetCursor();
	for (int i=0; i<arr.GetColumnCount(); i++) {
		s << arr.Get(int_row, i);
		s << ":::";
      }


Luigi


If you are going to write your data into *.txt file, everything must be string or char. According to my knowledge... Or do you know other methods?
If yes, then converting to string is useful.

Also you need kind of a record structure (format)? column and rows delimiters?
Re: Getting data in a row of ArrCtrl [message #2210 is a reply to message #2206] Tue, 04 April 2006 01:55 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Quote:


If I have understood, in this last example all the cells finish in 's' separated by ":::". Is this correct? It is evident that the operator '<<' does a continues strcat(...), it isn't. (Sometimes I feel to be a dinosaur... but I'm enjoing the short and powerfull syntax of C++ ).


Yes, it appends at the end in this case. This way you can prepare your records for importing into let's say ODBC, MS Excell etc.
Re: Getting data in a row of ArrCtrl [message #2217 is a reply to message #2208] Tue, 04 April 2006 10:38 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Tue, 04 April 2006 01:34


Btw, there is an easy possibility to edit cells directly in the ArrayCtrl like in spreadsheets... Maybe it's better to use those edit fields only just for searching. Just an idea...



It is a great idea. So far I was implementing what already existed with the old GUI where I hadn't a worderful arrayctrl.
Really this simplify the thing. I must add a row after each ADD_Player click and can't be empty line. If you have some guideline I can try it.

Quote:


Btw, why don't you want to use xml format?


Excuse me , Confused , XML to do what? (I know very little, just its name, about it)

Quote:


Also you need kind of a record structure (format)? column and rows delimiters?


At some moment I need to read all the cells of the array and get the information for all players. These finish in some record structure mantained in memory. By the way, has U++ some internal database? In this case I can use it and dismiss my structure. It could be useful for sort operation with respect to field 'date', 'name' and someother integer based. I'm thinking (dreaming) to click on a header and a sort is done with respect that field (I can die after that Smile ).

When I need to save the data the records finish '\n' delimited in a txt file in which each datacoloumn is separated by a ';' delimiter. As you see there is nothing sophisticated because fondamentally it is not a database application.

I'll try to use the chance you give me Smile . Unfortunately on next Friday I must take a pause of one week... but after that I'll run at the speed light Smile

Thank you!
Luigi
Previous Topic: "Forlano tabs" - how to reduce a headache by the proper use of the designer...
Next Topic: "Forlano tabs" - fill EditFields from ArrayCtrl Row...
Goto Forum:
  


Current Time: Thu Apr 18 17:05:39 CEST 2024

Total time taken to generate the page: 0.01675 seconds