如何从列表控件中获取旧值 [英] How to get the old value from list control

查看:54
本文介绍了如何从列表控件中获取旧值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关列表控件中某些问题的帮助.
我正在使用mfc的简单列表控件,我也想通过更改属性表及其完美工作来使其可编辑.
问题:我只想以这样一种方式来制作列表,使得列表控件中没有可用的重复数据.

注意:例如,我确实有一种解决方案,例如在事件LVN_ITEMCHANGED中将值存储在成员变量中,然后在事件LVN_ENDLABELEDIT中进行检查,如果发现数据已存在,则必须替换该值.由旧值控制列表.

问题:假设我确实编辑了一个项目并且不更改选择,然后再次单击进行编辑并输入了一些已经存在的值,那么倒数第二个而不是最后一个将被替换,这是因为LVN_ENDLABELEDIT事件不会被调用以获取最后一个值.
所以我需要某种帮助.
仅通过使用LVN_ENDLABELEDIT就有可能具有这种属性,并且我可以通过结构NMLVDISPINFOLV_DISPINFO获得列表控件的旧值吗?

我不想使用LVN_BEGINLABLEEDIT事件,因为它每次我在item中编辑文本时都会调用.

谢谢
我自己:在该块上有个新孩子.

I need some help regarding some problem in my list control .
I am using simple list control of mfc also i want to make it editable which i did by changing in property sheet and its perfectly working.
Question: i just want to make list such a way that no duplicate data is available in the list control.

Note: i do have one solution for example i store the value before editing in a member variable in event LVN_ITEMCHANGED and later check in event LVN_ENDLABELEDIT and if it is found data already exist then i do have to replace the value of the list control by the old value.

ISSUE: Suppose i do edit an item and do not change the selection then again i click for editing and do enter some values which is already existing then the second last value will be replaced not the last one.It is because the LVN_ENDLABELEDIT event is not being called to get the last value.
So what i need some kind of help.
Is it possible to have such kind of property just by using LVN_ENDLABELEDIT and i can get the old value of list control by the structure NMLVDISPINFO or LV_DISPINFO?

I don''t want to use the LVN_BEGINLABLEEDIT event as it calls everytime i edit a text in item.

Thank you
me myself :D new kid on the block.

推荐答案

创建一个临时字符串变量.用户曾经需要进行新的编辑时,首先将旧数据保存到临时字符串中.如果成功保存了新数据,则清除字符串,否则,如果重命名失败,则从临时字符串中恢复,然后清除它(不要集中在清除字符串上)
Create A Temporary String variable. When ever user would request for new edit first save the old data to the temporary string. If new data saved successfully then clear the string else if rename failed then restore from the temporary string and then clear it(dont focus on clearing string)


这篇关于如何从列表控件中获取旧值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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