You are on page 1of 2

E443 - How to enable in-place editing in the WinForms tree List View (TreeListEditor) | DevExpress Support Center

25-May-15
Log In

Products

Free Trials & Demos

SUPPORT CENTER

Buy

Support
Tickets

My Account
Examples

About Us
Localization

FAQ

Submit a Support Ticket

Type search string and press Enter

Training Events

How to enable in-place editing in the WinForms tree List View (TreeListEditor)

ID:
E443

Tags: .NET, Frameworks (XAF & XPO), eXpressApp Framework

Mo dified O n :
3/2/2015 9:00:27 PM

This example shows how to implement a custom ViewController that gets access to the TreeList control and makes it editable according to
the XtraTreeList documentation:
WinForms Controls > Controls > Tree List > Feature Center > Data Editing
TreeListOptionsBehavior.Editable Property
TreeList.ShowingEditor Event
TreeList.CellValueChanged Event
Take special note that special handling is required for the correct operation of editors for reference properties (e.g., a lookup filtering
functionality requires obtaining the currently selected record).
This is not a complete solution and you will need to modify and test this example code further in other scenarios according to your business
requirements. For instance, if you require supporting ConditionalAppearance rules, consider using the code from the Q479878 ticket. If you
require supporting member-level security permissions, consider extending this example by analogy with
the DevExpress.ExpressApp.Win.SystemModule.GridListEditorMemberLevelSecurityController class for GridListEditor.

Tech n o lo gy:
.NET
Platfo rm:
Framew o rks (XAF & XPO )
Pro du ct:
eXp ressAp p Framew o rk

Downloads
Examp le
Examp le Ru n n er

See also:
How to enable in-place editing in the ASP.NET tree List View (ASPxTreeListEditor)
ListEditors.TreeList - Make it possible to edit data directly in the tree list (inplace/inline edit)

Show all comments

TreeListInplaceEditViewController.cs

C#

Leave a Comment

v2013 vol 1.4 - v2014 vol 2.7


Open in popup window

using
using
using
using
using
using
using
using
using
using

System;
DevExpress.Xpo;
DevExpress.ExpressApp;
DevExpress.XtraTreeList;
DevExpress.ExpressApp.DC;
DevExpress.ExpressApp.Model;
DevExpress.ExpressApp.Win.Core;
DevExpress.XtraEditors.Repository;
DevExpress.ExpressApp.Win.Controls;
DevExpress.ExpressApp.TreeListEditors.Win;

namespace WinSolution.Module.Win {
public class TreeListInplaceEditViewController : ViewController<ListView> {
private ObjectTreeList treeList;
protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
TreeListEditor treeListEditor = View.Editor as TreeListEditor;
if (treeListEditor != null) {
treeList = (ObjectTreeList)treeListEditor.TreeList;
if (treeListEditor.AllowEdit) {
treeList.OptionsBehavior.Editable = true;
foreach (RepositoryItem ri in treeList.RepositoryItems)
ri.ReadOnly = false;
foreach (TreeListColumnWrapper columnWrapper in treeListEditor.Columns) {
IModelColumn modelColumn = View.Model.Columns[columnWrapper.PropertyName];
if (modelColumn != null)
columnWrapper.Column.OptionsColumn.AllowEdit = modelColumn.AllowEdit;
}
treeList.CellValueChanged += treeList_CellValueChanged;
treeList.ShownEditor += treeList_ShownEditor;
treeList.OptionsBehavior.ImmediateEditor = true;
}
}
}
protected override void OnDeactivated() {
if (treeList != null) {
treeList.CellValueChanged -= treeList_CellValueChanged;
treeList.ShownEditor -= treeList_ShownEditor;
}
base.OnDeactivated();
}
private void treeList_ShownEditor(object sender, EventArgs e) {
IGridInplaceEdit activeEditor = treeList.ActiveEditor as IGridInplaceEdit;
if (activeEditor != null && treeList.FocusedObject is IXPSimpleObject) {
activeEditor.GridEditingObject = treeList.FocusedObject;
}
}
private void treeList_CellValueChanged(object sender, CellValueChangedEventArgs e) {
object newValue = e.Value;
if (e.Value is IXPSimpleObject)
newValue = ObjectSpace.GetObject(e.Value);
object focusedObject = treeList.FocusedObject;
if (focusedObject != null) {
IMemberInfo focusedColumnMemberInfo = ObjectSpace.TypesInfo.FindTypeInfo(focusedObject.GetType()).FindMember(e.Column.FieldName);
if (focusedColumnMemberInfo != null)
focusedColumnMemberInfo.SetValue(focusedObject, Convert.ChangeType(newValue, focusedColumnMemberInfo.MemberType));
}
}
}
}

https://www.devexpress.com/Support/Center/Example/Details/E443

1/2

E443 - How to enable in-place editing in the WinForms tree List View (TreeListEditor) | DevExpress Support Center

DEVEXPRESS
About Us
News
Our Awards
Upcoming Events
User Comments
Case Studies
Reviews and Publications
Licensing
Purchasing
MVP Program
Contact Us
Logos

.NET CONTROLS
WinForms
ASP.NET
MVC
WPF
Silverlight
Windows 8 XAML
CROSS PLATFORM
Reporting
Document Automation

25-May-15

MOBILE
DevExtreme Mobile

HTML5 JS WIDGETS
DevExtreme Web

ENTERPRISE TOOLS
Report Server
Analytics Dashboard

iOS 7
DataExplorer

FRAMEWORKS
eXpressApp Framework
CODE-DEBUG-REFACTOR
CodeRush for Visual Studio

FUNCTIONAL WEB TESTING


TestCafe
DELPHI C++BUILDER
VCL

SUPPORT
Search the Knowledge Base
My Questions
Code Examples
Getting Started
Demos
Documentation
Blogs
Training
Webinars
Current Version/Build
Version History

FOLLOW US
If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business


Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance
HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether
using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you
build and deliver your best in the shortest time possible.

Your Privacy - Legal Statements

https://www.devexpress.com/Support/Center/Example/Details/E443

Copyright 1998-2014 Developer Express Inc.


All trademarks or registered trademarks are property of their respective owners

2/2

You might also like