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 » Range paste for GridCtrl
Range paste for GridCtrl [message #8539] Fri, 16 March 2007 16:26 Go to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
I can edit cells having added edit ctrls to each column. However, I can't select rectangular regions and more importantly, the paste only appears to work inside the edit control. When I try to paste a range of cells that I've copied from Excel, nothing happens.

Is there something I'm missing or is the paste function not implemented yet? Seems like if you could copy and paste from Excel then everything else is easy. If its not implemented I don't understand why the paste menu is there. Also, when I select two cells in a column the cells in the adjacent column get selected (I've turned off row select).

GridCtrl looks great and I realise its probably still under development.

Cheers,

Nick
Re: Range paste for GridCtrl [message #8550 is a reply to message #8539] Fri, 16 March 2007 21:40 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

nixnixnix wrote on Fri, 16 March 2007 11:26

I can edit cells having added edit ctrls to each column. However, I can't select rectangular regions and more importantly, the paste only appears to work inside the edit control. When I try to paste a range of cells that I've copied from Excel, nothing happens.


Hold ctrl to make recatngural selection.
Pasting text and excel is unavailable now (lack of time..) but it will be implemented after releasing 2007.1. If you see at Paste routine you'll find //todo (add a proper code if you want there Wink )
	GridClipboard gc = GetClipboard();
	if(gc.data.IsEmpty())
	{
		if(IsClipboardAvailableText())
		{
			Vector<String> lines = Upp::Split(ReadClipboardText(), '\n');
			for(int i = 0; i < lines.GetCount(); i++)
			{
				Vector<String> cells = Upp::Split(lines[i], ' ');
				//todo..
			}
		}
		return;
	}



Quote:


If its not implemented I don't understand why the paste menu is there. Also, when I select two cells in a column the cells in the adjacent column get selected (I've turned off row select).


Something to fix. I will take a look ASAP.
Quote:


GridCtrl looks great and I realise its probably still under development.


Yes, but in current form it should be quite stable and usable. I will write a better documentation soon to show you the all hidden power Smile

PS: I have merging cells in 60% implemented - this will be next major future.
PS2: Thanks for reporting bugs!
Re: Range paste for GridCtrl [message #8551 is a reply to message #8550] Fri, 16 March 2007 22:42 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks, yes I see it now.

Am tempted to have a go at writing something myself just now as I can see the values from my excel copy coming through loud and clear Very Happy

Perhaps if I get it working the way I want, I'll post it here s you have the option of tidying it up and including it in a future release

BTW (sliding off topic) as there is no TRACE in UPP, I am currently debugging with PromptOK(). Is the something better?

anyway inserting the code below and pasting 2x2 cells from excel makes it pretty obvious what is going on


GridClipboard gc = GetClipboard();
if(gc.data.IsEmpty())
{
if(IsClipboardAvailableText())
{
Vector<String> lines = Upp::Split(ReadClipboardText(), '\n');
for(int i = 0; i < lines.GetCount(); i++)
{
Vector<String> cells = Upp::Split(lines[i], '\t'); // tab not space
//todo..
//################################## my code - remove later
PromptOK("new line");
for(int j=0;j<cells.GetCount();j++)
{
String s = Format("##%s##",cells[j]);
PromptOK(s);
}
//##################################
}
}
return;
}



I will continue and get it the way I want it then post and you can see if you think its worth including.

Cheers for setting me on the path Smile

Nick

[Updated on: Fri, 16 March 2007 22:44]

Report message to a moderator

Re: Range paste for GridCtrl [message #8554 is a reply to message #8551] Fri, 16 March 2007 23:07 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
ok here is my code


void GridCtrl::Paste(int mode)
{
if(!clipboard)
return;

GridClipboard gc = GetClipboard();
if(gc.data.IsEmpty())
{
if(IsClipboardAvailableText())
{
Point start(curpos);
int ncol,nrow;

Vector<String> lines = Upp::Split(ReadClipboardText(), '\n');
for(int i = 0; i < lines.GetCount(); i++)
{
Vector<String> cells = Upp::Split(lines[i], '\t'); // tab not space
for(int j=0;j<cells.GetCount();j++)
{
ncol = start.x + j - 1;
nrow = start.y + i - 1;

this->Set(nrow, ncol, cells[j]);
}
}
}
return;
}


seems to work fine

Nick
Re: Range paste for GridCtrl [message #8555 is a reply to message #8554] Sat, 17 March 2007 01:14 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
here's something - I get this warning

warning: inline function `Upp::Item& Upp::GridCtrl::GetItem(int, int)' used but never defined

you seen that? easy to fix?

Nick


Re: Range paste for GridCtrl [message #8570 is a reply to message #8554] Sun, 18 March 2007 16:55 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Thanks for the '\t'! Unfortunately I can't directly use your code as it must respect callbacks (WhenInsert/UpdateRow etc). But I'll try to add it before next release.
Re: Range paste for GridCtrl [message #8573 is a reply to message #8570] Sun, 18 March 2007 22:01 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

unodgs wrote on Sun, 18 March 2007 11:55

Thanks for the '\t'! Unfortunately I can't directly use your code as it must respect callbacks (WhenInsert/UpdateRow etc). But I'll try to add it before next release.

Ok. Added.

PS: Could you post any screenshots regarding adjacent cell selection problem. I can't reproduce it.. (what version do you use?)
Re: Range paste for GridCtrl [message #8598 is a reply to message #8573] Tue, 20 March 2007 17:20 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
I am using 2007.1rc3

in the screen capture below, I selected only cells in the left most
column.

index.php?t=getfile&id=495&private=0

perhaps I have a setting wrong?

BTW, I've noticed that for pasting from tables in Adobe PDFs, the space is the correct separator (as you originally had it). Would it be possible for the new version to use both? So it would split rows based on newline and split cells based on space or tab?

Cheers, keep up the good work Smile anything I can do to help, just let me know,

Nick


Re: Range paste for GridCtrl [message #8601 is a reply to message #8598] Tue, 20 March 2007 20:01 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Quote:

BTW, I've noticed that for pasting from tables in Adobe PDFs, the space is the correct separator (as you originally had it). Would it be possible for the new version to use both? So it would split rows based on newline and split cells based on space or tab?

Yes, but how to distinguish which one is correct - the only information I have is the text clipboard is available. Probably both adobe and excel store clipboard in native formats. I have to investigate.

As for the bug: how do you select the cells. Do you hold shift? or ctrl + mouse? the first one selects block like in the text editor the second makes rectangular selection (BTW: In my internal version it is possible to make rect. sels with ctrl and cursors). If you press ctrl and use mouse please put your code reffering to grid initialization (adding columns, setting properties) here.
Re: Range paste for GridCtrl [message #12466 is a reply to message #8601] Sun, 04 November 2007 04:33 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks Daniel,

The ctrl + cursor works good (if a little non-standard) but when I go to cut and paste, only the last value out of my selection gets pasted to the new location and only one cell when I cut a whole column of 26 cells.

Is this by design? Is there a way to cut and paste multiple selections please?

Nick

[Updated on: Sun, 04 November 2007 04:34]

Report message to a moderator

Re: Range paste for GridCtrl [message #12482 is a reply to message #12466] Mon, 05 November 2007 13:17 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Hi!
Could you explain step by step what should I do to reproduce the incorrect behaviour. I don't exactely know what you mean. Right now I don't see any errors in copy & pasting.
Re: Range paste for GridCtrl [message #12596 is a reply to message #12482] Fri, 09 November 2007 22:42 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Its only when I have one-click edit enabled. I'm not sure it is a problem. If you want users to be able to copy and paste then all one needs to do is disable one click edit. I just disabled it and its fine.

Nick
Re: Range paste for GridCtrl [message #13361 is a reply to message #8539] Thu, 03 January 2008 03:23 Go to previous messageGo to next message
fuqr is currently offline  fuqr
Messages: 16
Registered: July 2007
Location: Singapore
Promising Member
Dear Nick,
I also met the problem of cutting & pasting multiple selections. I'm interested in your workaround: "disable one-click edit disable". But could you please explain how to disable "one-click edit" ? Razz
Thanks in advance,
Qinrong
Re: Range paste for GridCtrl [message #13363 is a reply to message #13361] Thu, 03 January 2008 08:35 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Please write about your problems. I started to fix copy/pasting yesterday and I'll be glad to fix all your bugs
Re: Range paste for GridCtrl [message #13364 is a reply to message #8539] Thu, 03 January 2008 10:10 Go to previous messageGo to next message
fuqr is currently offline  fuqr
Messages: 16
Registered: July 2007
Location: Singapore
Promising Member
Thanks Daniel,
Please refer to my question:
"Repeated Question: How to use Clipboard in DB(SqLite3)? [message #13331]".
I saw this issue (Range paste for GridCtrl) is related to my question and I'm interested in Nick's workaround. Razz

Best Regards,
Qinrong
Re: Range paste for GridCtrl [message #13369 is a reply to message #13361] Thu, 03 January 2008 14:10 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Hi Qinrong,

The easiest way to disable one-click edit is to not tick it in the layout designer.

The other way is to use

GridCtrl::OneClickEdit(false);

It just means that you have to double-click to start editing a cell rather than editing starting as soon as you click on a cell. Its not much of a workaround really. It just makes selecting cells easier.

Really though, Daniel is the author of the GridCtrl and it is his baby so you should look to him for real solutions, especially as he is seeking input just now on how copy-paste behaviour should work.

Happy new year everyone,

Nick
Re: Range paste for GridCtrl [message #13402 is a reply to message #13364] Fri, 04 January 2008 00:10 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Ok. Pasting should work ok now. At least in HomeBudget does. Tomorrow it should be in svn. Please try it. There may still be some bug though Smile
Re: Range paste for GridCtrl [message #13404 is a reply to message #8539] Fri, 04 January 2008 02:55 Go to previous message
fuqr is currently offline  fuqr
Messages: 16
Registered: July 2007
Location: Singapore
Promising Member
Thanks Nick and Daniel,
I'll try the updated svn later.

Best Regards,
Qinrong Razz
Previous Topic: How to change GridCtrl background color
Next Topic: How to do column resizing after ShowColumn() or HideColumn()?
Goto Forum:
  


Current Time: Fri Mar 29 00:38:43 CET 2024

Total time taken to generate the page: 0.01654 seconds