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 » Copy GridCtrl cell when read only
Copy GridCtrl cell when read only [message #26301] Fri, 23 April 2010 00:33 Go to next message
koldo is currently offline  koldo
Messages: 3033
Registered: August 2008
Ultimate Member
Hello all

One question: Do you know if it is possible to copy a GridCtrl cell when grid is read only?

I want to have the grid in a state where it is not possible to edit but it is possible to select and copy cells.


Best regards
Iñaki
Re: Copy GridCtrl cell when read only [message #26843 is a reply to message #26301] Wed, 02 June 2010 04:36 Go to previous messageGo to next message
ktj9 is currently offline  ktj9
Messages: 17
Registered: April 2010
Promising Member
Emm... I need this pretty soon. I might be wrong, but it seems GridCtrl::colidx and GridCtrl::rowidx are set to the cell on LeftDown. Anyway, I don't see out-of-box copy-paste utilities. So I would imagine we need to subclass and override GridCtrl::Key, or wire a menu callback, or override GridCtrl::RightDown, or all of them.

[Updated on: Wed, 02 June 2010 04:37]

Report message to a moderator

Re: Copy GridCtrl cell when read only [message #26845 is a reply to message #26843] Wed, 02 June 2010 08:33 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

@Koldo, you can just make all rows non editable for a while you need it using Editable method. I know it's not comfortable and pretty but should work. I'll try to add ReadOnly method that do this.

@ktj9 GridCtrl supports copy/paste. Just activate it by
 grid.Clipboard() 
Re: Copy GridCtrl cell when read only [message #26847 is a reply to message #26845] Wed, 02 June 2010 09:14 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3033
Registered: August 2008
Ultimate Member
unodgs wrote on Wed, 02 June 2010 08:33

@Koldo, you can just make all rows non editable for a while you need it using Editable method. I know it's not comfortable and pretty but should work. I'll try to add ReadOnly method that do this.

Hello uno

I have this now:

	if (!readOnly)
		gridPlantas.Accept();
	else
		gridPlantas.Reject();


I have tried this, but the results are the same:
	for (int row = 0; row < grid.GetRowCount(); ++row)
		for (int col = 0; col < grid.GetColumnCount(); ++col)
			grid.GetItem(row, col).Editable(!readOnly);
(GetItem is really private Smile)

I have not found an Editable() method for rows.


Best regards
Iñaki
Re: Copy GridCtrl cell when read only [message #26849 is a reply to message #26847] Wed, 02 June 2010 09:21 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

I thought about Editable for rows Smile so your code could be simplified to:
for (int row = 0; row < grid.GetRowCount(); ++row)
     grid.GetRow(row).Editable(!readOnly);

This version is also faster.
Re: Copy GridCtrl cell when read only [message #26851 is a reply to message #26849] Wed, 02 June 2010 09:48 Go to previous message
koldo is currently offline  koldo
Messages: 3033
Registered: August 2008
Ultimate Member
unodgs wrote on Wed, 02 June 2010 09:21

I thought about Editable for rows Smile so your code could be simplified to:
for (int row = 0; row < grid.GetRowCount(); ++row)
     grid.GetRow(row).Editable(!readOnly);

This version is also faster.

Hello uno

Thanks for your fast response.

Unfortunately, these solution does not let to copy a cell in read only mode.

Other drawback is that it lets to follow editing a cell in read only mode if it was being edited previously. However Reject() is better as it ends any previous unfinished editing.


Best regards
Iñaki
Previous Topic: GridCtrl samples with all functions and methods
Next Topic: inconsistency causes crash
Goto Forum:
  


Current Time: Wed Nov 20 05:45:17 CET 2019

Total time taken to generate the page: 0.01537 seconds