LIST CONTROL编辑单元格
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Introduction
Almost every one of us who are programming in VC++ , will come across the List control. There are many cases where there is a need to represent data in List Control in multiple columns. By default it is not possible to modify the data in the List control itself. In this small article I am putting a simple way to edit any value in any column in a Report style List control. The logic here is simple, whenever user clicks on an sub-item which he wants to modify at that place I am displaying a edit box and allowing to modify the value. Once modified and by clicking the ENTER key, the updated value is set in the List control. Here I am assuming the user is familiar with VC++ and using Class Wizard
Implementation steps:
ing MFC AppWizard, create a Dialog Based application. Give the
application name as MultipleColumns. By default the wizard adds OK and
Cancel buttons to the Dialog, Remove these two buttons.
2.Now Add a List-Control and in properties change the style to Report, this
style is necessary if we want multiple columns
3.Add two buttons to the Dialog and name them as OK and Exit
4.Add one Edit box and in the properties remove the Border style
ing the Class Wizard add the message handlers for the OK and Exit
Buttons. Add the following code to those functions
6.Add a function called InsertItems() to the CMulipleColumnsDlg class.
In the function handler add the following code
7.Add another function called SetCell( ) to
the CMultipleColumnsDlg class
In the function handler add the following code
8.Add one more function called GetItemText() to the same Class
Inside the function add the following code
9.Also add two member variables to the CMultipleColumnsDlg class which
are of type int
10.From the Class wizard add NM_CLICK notification to the List control. Inside
the function handler write the following code
11.To handle the ENTER key we need to write the virtual function OnOk in
the MultipleColumnsDlg.h, so add the following as protected member
In MultipleColumnsDlg.cpp write the following code.
12.The last step in the implementation is add the following code in side
the OnInitDialog function
Conclusion
With this I will hope , it will give an idea to edit any sub items in a List control. License
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here