• About
    • Blog
    • Business Process
    • Charity Work
    • History
    • News
  • Services
    • Legacy System Support
    • Bespoke System Development
    • Web Design & Development
    • View all services
  • Products
  • Our work
    • Customers
    • Case Studies
  • Careers
  • Contact
Microsoft Partner - Application Development
4th September 2015

DevExpress Unbound Fields

Bespoke Development C# Custom Development Custom Fields DevExpress PSP Knowledge Unbound Fields
DevExpress Unbound Fields

Scenario

Recently we implemented the DevExpress Notifications module into one of our projects. The functionality worked great however we wanted to improve the functionality and add our own defined fields to the notifications pop-up screen. The solution below shows how to add custom fields to predefined or hardcoded lists which cannot be added to though using the Model.

Solution

After researching the functionality we found that adding Unbound Fields to the notifications pop-up screen would be the best solution. We created a new View Controller within the Module.Win project to override the default functionality and add our own custom fields to notification listing on the pop-up screen, this view controller is shown below.

/// <summary>
/// Win Notification View Controller
/// </summary>
public partial class WinNotificationViewController : ViewController<ListView>

/// <summary> /// Initializes a new instance of the <see cref="WinNotificationViewController"/> class. /// </summary> public WinNotificationViewController()

this.InitializeComponent(); this.TypeOfView = typeof(ListView); this.TargetViewType = ViewType.ListView; this.TargetObjectType = typeof(Notification);

/// <summary> /// Called when [activated]. /// </summary> protected override void OnActivated()

base.OnActivated(); View.Editor.ControlsCreated += this.Editor_ControlsCreated;

/// <summary> /// Handles the ControlsCreated event of the Editor control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void Editor_ControlsCreated(object sender, EventArgs e)

GridListEditor listEditor = ((ListView)View).Editor as GridListEditor; if (listEditor != null)

GridView gridView = listEditor.GridView; gridView.CustomUnboundColumnData += new DevExpress.XtraGrid.Views.Base.CustomColumnDataEventHandler(this.GridView_CustomUnboundColumnData); GridColumn alarmTime = gridView.Columns.Add(); alarmTime.VisibleIndex = 2; alarmTime.Caption = "My Custom Field"; alarmTime.FieldName = "MyCustomField"; alarmTime.UnboundType = DevExpress.Data.UnboundColumnType.DateTime; alarmTime.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;

/// <summary> /// Handles the CustomUnboundColumnData event of the gridView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs"/> instance containing the event data.</param> private void GridView_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)

MyNotification object = (MyNotification)((Notification)e.Row).NotificationSource; if (object != null && e.IsGetData)

switch (e.Column.FieldName)

case "MyCustomField": e.Value = object.MyCustomField; break;

The functionality above can be used to add unbound/custom fields to Grid List Editors thought out your DevExpress application.

Share:
PSP IT Design & Development
About Us
  • Privacy Policy
  • History
  • Customers
  • News
  • Blogs
Services
  • Legacy System Modernisation
  • Website Design & Development
  • Bespoke Application Development
  • Outsource IT Strategy
  • All Services
Contact
  • 01775 722377
  • letstalk@psp-it.co.uk
  • Carver House, Apex Court, Spalding Office Park, Elsoms Way, Pinchbeck, Spalding,Lincolnshire, PE11 3UL

Terms & Conditions Privacy Policy

© PSP People Systems Process Ltd. 2022. All Rights Reserved.

MENU

MENU

  • About

    • Blog

    • Business Process

    • Charity Work

    • History

    • News

  • Services

    • Legacy System Support

    • Bespoke System Development

    • Web Design & Development

    • View all services

  • Products

  • Our work

    • Customers

    • Case Studies

  • Careers

  • Contact

© PSP People Systems Process Ltd. 2022. All Rights Reserved. Privacy Policy

give us a call
01775 722377
drop us an email