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 » GridCtrl Paste issue (fixed)
GridCtrl Paste issue (fixed) [message #47370] Mon, 09 January 2017 15:26 Go to next message
mirek is currently offline  mirek
Messages: 12022
Registered: November 2005
Ultimate Member
I have tried to fix following issue:

The code is pasting text into GridCtrl which has column EditDouble editors. Now text is pasted as text and clicking on EditDouble column cell crashes (because the cell value is text instead of number).

First I have fixed it with WhenCellPaste (IMO that one is supposed for that), however in the project the issue is widespread. So I started thinking and in the end changed GridCtrl::Set0 this way (just the important part):

	Ctrl *ctrl = items[ri][c].ctrl;
	bool  setctrl = true;
	if(!ctrl) {
		ctrl = edits[c].ctrl;
		setctrl = ctrlid.y == ri;
	}
	
	if(ctrl) {
		if(paste && IsString(val)) {
			Convert *cv = dynamic_cast<Convert *>(ctrl);
			if(cv)
				val = cv->Scan(val);
		}
		if(setctrl)
			ctrl->SetData(val);
	}



Basically, if this is 'paste' and the cell where we are pasting has editor derived from Convert, and the value is text, we use this Convert to convert text to appropriate Value.

I believe that this patch is as unintrusive as it gets and should not broke anything, but 2nd opinion is always great...

Mirek
Re: GridCtrl Paste issue (fixed) [message #47371 is a reply to message #47370] Mon, 09 January 2017 20:02 Go to previous message
unodgs is currently offline  unodgs
Messages: 1354
Registered: November 2005
Location: Poland
Senior Contributor

LGTM Smile
Previous Topic: Using an Array to switch displayed image
Next Topic: Declare some methods of ArrayCtrl as protected
Goto Forum:
  


Current Time: Sun Sep 22 20:13:51 CEST 2019

Total time taken to generate the page: 0.00860 seconds