KB Article A1237
Visible to All Users

How to register a custom editor for use in the XtraGrid

Description:
I've created my own editor derived from XtraEditors. What should I do to be able to add my editor to the grid's repository at design time?

Answer:
Applies to:
XtraGrid, XtraTreeList, XtraVerticalGrid, XtraBars
You should create a RepositoryItem class for your editor and declare a static (Shared in VB.NET) constructor and a Register method in it. The RepositoryItem class must be marked with the UserRepositoryItemAttribute attribute pointing to the Register method. It is also necessary to override the EditorTypeName property in both editor classes: RepositoryItem and BaseEdit descendants.

C#
using DevExpress.XtraEditors; using DevExpress.XtraEditors.Repository; using DevExpress.XtraEditors.Registrator; namespace CustomEditors { [UserRepositoryItem("Register")] public class RepositoryItemMyButtonEdit : RepositoryItemButtonEdit { static RepositoryItemMyButtonEdit() { Register(); } public RepositoryItemMyButtonEdit() {} internal const string EditorName = "MyButtonEdit"; public static void Register() { EditorRegistrationInfo.Default.Editors.Add(new EditorClassInfo(EditorName, typeof(MyButtonEdit), typeof(RepositoryItemMyButtonEdit), typeof(DevExpress.XtraEditors.ViewInfo.ButtonEditViewInfo), new DevExpress.XtraEditors.Drawing.ButtonEditPainter(), true, null, typeof(DevExpress.Accessibility.ButtonEditAccessible))); } public override string EditorTypeName { get { return EditorName; } } } public class MyButtonEdit : ButtonEdit { static MyButtonEdit() { RepositoryItemMyButtonEdit.Register(); } public MyButtonEdit() {} public override string EditorTypeName { get { return RepositoryItemMyButtonEdit.EditorName; } } [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public new RepositoryItemMyButtonEdit Properties { get { return base.Properties as RepositoryItemMyButtonEdit; } } protected override void OnClickButton(DevExpress.XtraEditors.Drawing.EditorButtonObjectInfoArgs buttonInfo) { ShowPopupForm(); base.OnClickButton(buttonInfo); } protected virtual void ShowPopupForm() { using(Form form = new Form()) { form.StartPosition = FormStartPosition.Manual; form.Location = this.PointToScreen(new Point(0, Height)); form.ShowDialog(); } } } }

Note: You should build the attached sample project prior to opening Form1 in design mode to avoid error messages about not found classes.
See Also:
Custom Editors
The Controls demo shipped with the XtraEditors
How to use a custom control in inplace mode in DevExpress containers
How to create a GridView descendant class and register it for design-time use
How to change a default in-place editor automatically created by the grid for specific column types

Comments (2)

    Can We Bind LookUpEdit to a particular GridControl Cell.

    Alisher (DevExpress Support) 11 years ago

      Hi,
      I've created a new ticket (Q462247) on your behalf. Please refer to it for further correspondence.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.