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 » Handle editable value in GridCtrl
Handle editable value in GridCtrl [message #23952] Wed, 09 December 2009 17:03 Go to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Uno

I wanted to derive GridCtrl to have a very basic SpreadSheet control.

To get that, I wanted to keep per cell the formula and the value to be visualized.

The behavior should be: If the cursor is in the cell, the formula is visualized and if not, the value is visualized.

I have tried some ways but without success:

- To prepare a Cell class with members value (Value) and formula (String).

Every cell in the GridCtrl is set a Cell, like in
	grid.Set(23, 45, Cell(5, "2+3"));


This is slow for big GridCtrls

And Cell class has:
	operator Value() { return RawToValue<Cell>(*this); }


A Convert class is used to visualize the value:
	Value Format(const Value &q) const {
		if (q.IsNull())
			return Null;
		else if (IsTypeRaw<Cell>(q)) {
			const Cell &pv = ValueTo<Cell>(q);
			return pv.value;
		} else
			return "Unknown";
	}


But I do not know how to show the formula when the cursor is in the cell, and how to get the edited value to be set in the Cell formula member.


- To have an Array <Cell> like previous (without value as value is itself in the GridCtrl)

But I have the same problem: I do not know to show the formula and not the value when the cursor is in the cell.

Do you have any idea ?

Best regards
Koldo


Best regards
Iñaki
Re: Handle editable value in GridCtrl [message #23953 is a reply to message #23952] Wed, 09 December 2009 18:13 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Uno

Perhaps other focus would be to have an EditString that would appear on the selected cell when double clicked.

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

The problem I have is that I do not know the location of the double-clicked cell to fit on it the EditString.

In the screenshot the cell with "20" has been double clicked, the EditString is filled with the right formula (12+8 = 20), but it should be moved and sized on the selected cell.

Best regards
Koldo
  • Attachment: Dib.PNG
    (Size: 5.11KB, Downloaded 647 times)


Best regards
Iñaki
Re: Handle editable value in GridCtrl [message #23958 is a reply to message #23953] Thu, 10 December 2009 10:43 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Uno

Following the last option I have found the function GetItemRect(row, col) that returns the Rect of the cell indicated.

The bad thing is that it is private Sad and that I will have to find something to resize the EditString over the cell when resizing the column.

Best regards
Koldo


Best regards
Iñaki
Re: Handle editable value in GridCtrl [message #23977 is a reply to message #23958] Sun, 13 December 2009 21:51 Go to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Hi!
Very interesting problem. I tried to do it using similar to yours approach but I failed too. I think I'll introduce new API to handle this problem. I won't give you any details right now but expect it very soon.
Previous Topic: Paste column in GridCtrl
Next Topic: How to add HeaderCtrl to DocEdit?
Goto Forum:
  


Current Time: Fri Apr 19 05:38:35 CEST 2024

Total time taken to generate the page: 0.01432 seconds