in
Forums
Blogs
Files
Devexpress.Com
ClientCenter
Support Center
DevExpress Channel

Windows Forms

April 2008 - Posts

  • XtraLayout Control: New Features for Runtime Layout Customization

    In version 2008 vol 1, the XtraLayout control gives you greater flexibility for runtime layout customization. The control introduces three new features that allow you to make the UI more user-oriented.

    Implementing a Custom Customization Form

    You can now create your own Customization Form on the fly at design time, implementing custom logic or arranging customization controls in a custom manner. In addition to custom controls, with a few mouse clicks, you can add any of the standard controls supported by the default Customization Form to your own form:

    Implementing a Custom Customization Form

    These standard controls will be automatically integrated into the XtraLayout control's infrastructure. Here is an example of the custom Customization Form displaying the Button Panel, Hidden Item List and a custom 'Restore All' button:

    Implementing a Custom Customization Form

    See How to: Create custom customization form, for an example.

    Creating a Custom "Fixed" Layout Item

    There are a few predefined service layout items which are "fixed" to the Customization Form - Empty Space Item, Label, Separator and Splitter. These items are always available in the Customization Form, and when an end-user drags and drops them onto the XtraLayout control, they are cloned.

    In the current version, you can easily add custom "fixed" items to the Customization Form. For instance, you can create a "fixed" item that represents a LinkLabel control. So, when and end-user drags and drops this item onto the form, an instance of the layout item containing a LinkLabel is created and added to the layout.

    To implement a custom "fixed" item, create a LayoutControlItem class descendant and implement the IFixedLayoutControlItem interface.

    public class MyFixedLabelItem : LayoutControlItem, IFixedLayoutControlItem {
        public MyFixedLabelItem() {
            this.controlCore = new LinkLabel();
            this.linkCore = "www.devexpress.com";
        }
        #region IFixedLayoutControlItem Members
        string IFixedLayoutControlItem.CustomizationName {
            get { 
                return "DevExpress Link"; 
            }
        }    
        Control IFixedLayoutControlItem.OnCreate() {
            TextVisible = false;
            ((LinkLabel)controlCore).LinkClicked += label_LinkClicked;
            return controlCore;
        }
        //...
        #endregion
    }
    

    The only other thing to do is to register the new item in the XtraLayout control via the RegisterFixedItemType method. The image below demonstrates a custom DevExpress Link "fixed" item below the Splitter item:

    Creating a Custom Fixed Layout Item

    For a complete example, see How to: Create custom 'fixed' item.

    Filtering Properties in the Customization Form

    In customization mode, an end-user can modify specific properties of layout items via the Property Grid control embedded into the Customization Form. You can simplify the UI by filtering the Property Grid, i.e. providing access only to specific, main properties and hiding other, unimportant properties. And, with the current version, you can do this in a straightforward way.

    First, create a wrapper object inheriting the BasePropertyGridObjectWrapper class that publishes the properties to be listed in the Property Grid:

    public class MyLayoutControlItemPropertyWrapper : BasePropertyGridObjectWrapper {
        protected LayoutControlItem Item { 
            get { return WrappedObject as LayoutControlItem; } 
        }
        public string Text { 
            get { return Item.Text; } 
            set { Item.Text = value; } 
        }
        //...
    }
    

    And then, associate the wrapper object with a particular type of layout item:

    layoutControl1.RegisterCustomPropertyGridWrapper(typeof(LayoutControlItem), typeof(MyLayoutControlItemPropertyWrapper));
    

    Now, when selecting any layout item of this type, the Property Grid will list only the selected properties:

    Filtering Properties in the Customization Form

    Refer to How to: Specify which properties to display in the Property Grid when selecting layout items, for a complete example.

  • XtraReports Screencast: Create a Cross-Tab Report

    <Update May 20, 2008>Check out the online demo to see a live example of a cross-tab report.</Update>

    Cross-Tab reports can be a great way to show summaries of data. What is a Cross-Tab report? As Oliver's says: "A cross table is basically the result of transposing some data and using one of the fields for a second dimension."

    The Problem

    Often you have sequential data like a list of orders. For example, orders that have dates and also a reference to a customer. In a linear report, you can group either by dates or by customers. And while you can also group by both, the result isn't what you want because you have to decide on the order of the grouping. So it would be great to have the dates in the row headers and the customers in column headers, or the other way round.

    The Solution

    Creating the SQL statement for a pivot table can be a headache. Why not simply drop a component on a form, point to your datasource and create the report using a designer? XtraReports makes it easy to create Cross-Tab reports. Check out this short 2 minute screencast which shows the simple drag-and-drop style to creating a complex Cross-Tab report.

    image

    You may also find the written version of this demo useful. If you want to read more about Cross-Tab in WinForms, then check out Oliver's blog post on this topic.

Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED