DevExpress WPF Grid Control - Editing Data - the missing pieces

WPF Team Blog
10 March 2009

In a previous post, I was looking at editing data with the WPF Grid. Unfortunately I stumbled upon a few issues with editor configuration back then. With 9.1 being tested internally, I decided it would be time to have a fresh look at things, and finally post an example on the configuration on editor type properties. As you will see, all is not perfect yet - but that's what testing phases are good for, of course.

Without further ado, here's how to configure settings for a column's editor:

<dxg:GridColumn FieldName="Population">

    <dxg:GridColumn.EditSettings>

        <dxe:ButtonEditSettings>

            <dxe:ButtonEditSettings.Buttons>

                <dxe:ButtonEditButtonInfo ButtonKind="Regular" Click="ButtonEditButtonInfo_Click" />

            </dxe:ButtonEditSettings.Buttons>

        </dxe:ButtonEditSettings>

    </dxg:GridColumn.EditSettings>

</dxg:GridColumn>

There are several pre-configured settings types, plus you can derive your own. These encapsulate both the editor to be used and its own settings, so deriving your own settings objects is a good way of creating reusable pre-configured editors.

In the case of the sample code above - well - as you can see, we'll need to fix something about those two buttons that come up although I configured only one. Hm.

Update: As these things go, the solution to this button issue was found almost immediately after I posted this article. It's not a bug, it's a feature! Well, at least it's something that has been done for certain technical reasons surrounding the design time control initialization/persistence mechanisms in WPF. So, to get rid of the one button that is included by default, the ButtonEditSettings instance must be configured like this (note the AllowDefaultButton attribute!):

<dxe:ButtonEditSettings AllowDefaultButton="False">

    <dxe:ButtonEditSettings.Buttons>

        <dxe:ButtonEditButtonInfo ButtonKind="Regular" Click="ButtonEditButtonInfo_Click" />

    </dxe:ButtonEditSettings.Buttons>

</dxe:ButtonEditSettings>

There are also several markup extensions included with the Grid control, which provide a shortcut for certain editor configurations. As an example (and this is not in my demo for this post, it's from our WPF grid demo that comes with DXperience 9.1), you could have a GridColumn that looks like this:

<dxg:GridColumn FieldName="ToId" Header ="To" SortMode="DisplayText" Width="100"

               EditSettings="{dxe:ComboBoxSettings IsTextEditable=false, ValueMember=Id,

               DisplayMember=Name, ItemsSource={x:Static local:OutlookData.Users}}" />

Unfortunately I don't think that all these options are fully documented yet - we are still in a pre-release phase after all. This blog isn't the right place for such docs either, so for the time being I can only recommend to have a good look around our libraries as well as demos, to pick up hints on what is possible. Docs will follow, promise!

Here's the sample code for this post: DxGridEditing2.zip

Please note that the sample is built for DXperience 9.1! I'm afraid you may have to wait just a little while longer to try it out yourself. It should be possible to use 8.3.x, but I haven't tried that - YMMV.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
Tags
No Comments

Please login or register to post comments.