最终数据网格内容为stl:map ::: get" focus" cell问题 [英] Ultimate data grid content to stl: map::: get"focused"cell problem

查看:80
本文介绍了最终数据网格内容为stl:map ::: get" focus" cell问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用地图中的内容动态填充数据网格。

有字段,可以更改。 Map键保存在cell.param()

方法中

OnEditVerify()我捕获禁止的击键

OnEditFinish():我想得到新的Cell内容(CString)并在它来自的stl:map中编辑它。 (按钮确定会将地图发送给目标。)



现在我的问题:

如果我使用onEditFinish,单元格的所有内容都被设置并能够复制到新鲜编辑的adn聚焦单元格旁边的地图。

这个单元格只显示空CString上下文:

如何获取所有单元格的内容,哪些功能是必要的?



我尝试了什么: <通过.chm文档读取




尝试调试出CUGCtrl

试图获得专注的单元格通过键盘锁定OnEditVerify的键(不好主意)



我可以在Grid失去焦点后获取内容(在OK Button功能中)

但这不是我想要的。



http://www.codeproject.com/Articles/20769/The-Ultimate-Grid-FAQ

http://www.codeproject.com/Articles/20187/The-Ultimate-Grid-Beginner-s-Guide

解决方案

我很久以前就使用过UG

这里有一个未经测试的样本让你开始进行单元格编辑



  int  MyCug :: OnEditFinish( int  col, long 行,CWnd *编辑,LPCTSTR字符串,BOOL cancelFlag)
{

UNREFERENCED_PARAMETER(* edit);
// 获取现有单元格内容
CString strOldText = QuickGetText(col,row );
// 获取修改的单元格内容
CString strNewText = string;

// 在此处验证新单元格内容
// 例如请求至少10个字符
if (strNewText.GetLength()< 10
{
// 向用户显示警告
AfxMessageBox(_T( 文本必须至少10个字符));
// 您也可以重置单元格内容(到未修改版本)
QuickSetText (列,行,strOldText);
// 返回false继续编辑
返回 FALSE;
}

// 新文本已经过验证,因此请更新单元格内容新文本
QuickSetText(col,row,strNewText);

// 在这里,您还可以更新数据源,(数据库,stl容器等) ..)

// 成功完成编辑
return TRUE;
}





注意:此代码尚未经过测试,仅用于解释逻辑

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

解决方案

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

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


这篇关于最终数据网格内容为stl:map ::: get&quot; focus&quot; cell问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆