Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i filled a data grid dynamicially with my content out of a map.
there are fields, which are changeable. The Map Key is saved in cell.param()
in the methods
OnEditVerify() i catch the forbidden keystrokes
OnEditFinish () : i wanna get the new Cell content (CString) and edit it inside the stl: map it comes from. (The Button Ok will send the map to the target.)

Now my problem:
if i use onEditFinish, all the Content of the Cells are set and able to copy into the map beside the "fresh" edited adn focused cell.
this cell only shows me the empty CString contet: ""
how can i get the content of all cells, which funktion is necessary?

What I have tried:

reading through the .chm documentation
trying to debug out of the CUGCtrl
trying to get the focused cell content by keylogging the Keys of "OnEditVerify"(bad idea)

I could get the content after the Grid lost focus (in OK Button fction)
BUT thats not what i want.

http://www.codeproject.com/Articles/20769/The-Ultimate-Grid-FAQ
http://www.codeproject.com/Articles/20187/The-Ultimate-Grid-Beginner-s-Guide
Posted
Updated 2-Mar-16 1:36am

1 solution

i have used UG a long time ago
here is a untested sample to get you started with cell editing

C++
int MyCug::OnEditFinish(int col, long row,CWnd *edit,LPCTSTR string,BOOL cancelFlag)
{
	
	UNREFERENCED_PARAMETER(*edit);
	//Get existing cell content
	CString strOldText = QuickGetText(col, row);
	//Get modified cell content
	CString strNewText = string;
	
	//Validate new cell content here 
	//For example request at least 10 characters
	if(strNewText.GetLength() < 10)
	{
		//Show warning to user
		AfxMessageBox(_T("The text must be minimum 10 characters"));
		//You may also reset cell content (to unmodified version)
		QuickSetText(col,row,strOldText);
		//Return false to continue editing
		return FALSE;
	}
	
	//The new text is validated ,so update cell content with new text
	QuickSetText(col,row,strNewText);
	
	//Here you may also update your data source , (database,stl container ,etc..)
	
	//Complete editing with success
	return TRUE;
}


Note: This code has not been tested ,written for only to explain logic
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900