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 » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ArrayCtrl copy to the Clipboard
ArrayCtrl copy to the Clipboard [message #22605] Thu, 30 July 2009 17:39 Go to next message
koldo is currently offline  koldo
Messages: 3033
Registered: August 2008
Ultimate Member
Hello all

How has to be defined an ArrayCtrl to let the user to copy the selected rows to the Clipboard ?

Best regards
Koldo


Best regards
Iñaki
Re: ArrayCtrl copy to the Clipboard [message #22702 is a reply to message #22605] Thu, 06 August 2009 14:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
There is no direct support - perhaps because the only hard part is the format, which cannot be preimplemented (you have to decide), putting on clipboard is then simple.

Mirek
Re: ArrayCtrl copy to the Clipboard [message #22703 is a reply to message #22702] Thu, 06 August 2009 16:17 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3033
Registered: August 2008
Ultimate Member
Hello Mirek

A sample that works for me is in GridCtrl.cpp, function GridCtrl::SetClipboard, where the separation between rows is with \r\n and between columns is with \t.

This way the cells are pasted well in MS Excel and in Open Office.

A thing to care with is not to add aditional tabs per row as in GridCtrl. This additional tab deletes the next column in Excel.

So to copy this:

First   Row
Second  Row

it has to be passed to the clipboard this:

"First\tRow\r\nSecond\tRow"

instead of this:

"First\tRow\t\r\nSecond\tRow\t"

Thank you very much
Koldo


Best regards
Iñaki
Re: ArrayCtrl copy to the Clipboard [message #22723 is a reply to message #22703] Sat, 08 August 2009 21:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
koldo wrote on Thu, 06 August 2009 10:17

Hello Mirek

A sample that works for me is in GridCtrl.cpp, function GridCtrl::SetClipboard, where the separation between rows is with \r\n and between columns is with \t.

This way the cells are pasted well in MS Excel and in Open Office.

A thing to care with is not to add aditional tabs per row as in GridCtrl. This additional tab deletes the next column in Excel.

So to copy this:

First   Row
Second  Row

it has to be passed to the clipboard this:

"First\tRow\r\nSecond\tRow"

instead of this:

"First\tRow\t\r\nSecond\tRow\t"

Thank you very much
Koldo


String s;
for(int i = 0; i < array.GetCount(); i++) {
    for(int j = 0; j < columns; j++) {
         if(j) s << '\t';
         s << AsString(array.Get(i,j);
    }
    s << "\r\n";
}
WriteClipboardText(s);


Mirek
Re: ArrayCtrl copy to the Clipboard [message #22730 is a reply to message #22723] Sun, 09 August 2009 17:32 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3033
Registered: August 2008
Ultimate Member
Thank you Mirek

This is the version I have included, adding IsSel to copy only selected rows.

	String s;
	
	for(int i = 0; i < array.GetCount(); i++) {
		if (array.IsSel(i)) {
		    for(int j = 0; j < array.GetColumnCount(); j++) {
		         if(j) 
		         	s << '\t';
		         s << AsString(array.Get(i,j));
		    }
		    s << "\r\n";
		}
	}
	WriteClipboardText(s);


To finish this it would be great to add it to ArrayCtrl Smile.

Best regards
Koldo


Best regards
Iñaki
Re: ArrayCtrl copy to the Clipboard [message #33921 is a reply to message #22730] Mon, 26 September 2011 14:45 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
koldo wrote on Sun, 09 August 2009 17:32

Thank you Mirek

This is the version I have included, adding IsSel to copy only selected rows.

	String s;
	
	for(int i = 0; i < array.GetCount(); i++) {
		if (array.IsSel(i)) {
		    for(int j = 0; j < array.GetColumnCount(); j++) {
		         if(j) 
		         	s << '\t';
		         s << AsString(array.Get(i,j));
		    }
		    s << "\r\n";
		}
	}
	WriteClipboardText(s);


To finish this it would be great to add it to ArrayCtrl Smile.

Best regards
Koldo


Hello Koldo,

I need to get the rows selected in an array. Is this snippet included in some ArrayCtrl method? I cannot find it.
Thanks,
Luigi
Re: ArrayCtrl copy to the Clipboard [message #33930 is a reply to message #33921] Tue, 27 September 2011 11:30 Go to previous message
koldo is currently offline  koldo
Messages: 3033
Registered: August 2008
Ultimate Member
Hello Forlano

I do not know. Finally I used GridCtrl. But it would be good to have this feature in ArrayCtrl.


Best regards
Iñaki
Previous Topic: GridCtrl and copy to clipboard
Next Topic: Export Ctrl to qtf table
Goto Forum:
  


Current Time: Wed Nov 20 21:08:28 CET 2019

Total time taken to generate the page: 0.01815 seconds