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

RepositoryItem relationship to Editor

Last post 11/28/2007 10:04 AM by Jeff Richardson. 2 replies.
Page 1 of 1 (3 items)
Sort Posts:
Previous Next
  • 11/9/2007 10:45 AM

    RepositoryItem relationship to Editor

    Can someone please explain the relationship between a RepositoryItem and the
    Editor. For example, the RepositoryItemLookUpEdit and the LookUpEdit. I
    understand that the RepositoryItem is used as a template to configured
    default values of the Editor and that some of the Editor Events are raised
    through the RepositoryItem (as if it were a wrapper around the Editor), but
    when does the Editor get instantiated and bound to the underlying DataSoure?
    How do you access the Editor from the DataSource? How do you access the
    Editor from the RepositoryItem?

    I have part of the puzzle but I'm looking for more information.
    The LookUpEdit.Properties will return the RepositoryItemLookUpEdit, but how
    do you go in the reverse direction?
    The RepositoryItemLookUpEdit is about the a GridColumn via the ColumnEdit
    property but how does this allow access to the LookUpEdit?

    TIA
  • 11/12/2007 4:55 AM In reply to

    Re: RepositoryItem relationship to Editor

     this is all documented in the docs. the RepositoryItem has a static constructor, that is run before the normal constructor, and that invokes the editor. here's how it is in an extension to LookUpEdit i wrote:

            /// <summary>
            /// Register the <see cref="LookUpEditEx"/> and <see cref="RepositoryItemLookUpEditEx"/>
            /// before the main constructor is called.
            /// </summary>
            /// <remarks>Calls <see cref="RegisterLookUpEditEx"/>.</remarks>
            static RepositoryItemLookUpEditEx()
            {
                RegisterLookUpEditEx();
            }

            /// <summary>
            /// Register this repository item and its editor
            /// </summary>
            public static void RegisterLookUpEditEx()
            {
                Image img = null;
                try
                {
                    img = (Bitmap)Bitmap.FromStream(Assembly.GetAssembly(typeof(LookUpEdit))
                        .GetManifestResourceStream("DevExpress.XtraEditors.Bitmaps256.LookUpEdit.bmp"));
                }
                catch
                {
                }
                EditorRegistrationInfo.Default.Editors.Add(new EditorClassInfo(_editorName,
                    typeof(LookUpEditEx), typeof(RepositoryItemLookUpEditEx), typeof(LookUpEditViewInfo),
                    new ButtonEditPainter(), true, img, typeof(PopupEditAccessible)));
            }

    you also have to override EditorTypeName:

            /// <summary>
            /// Get the name of the associated <see cref="LookUpEditEx"/> editor
            /// </summary>
            /// <value>The name of the editor</value>
            public override string EditorTypeName
            {
                get
                {
                    return _editorName; //_editorName=="LookUpEditEx"
                }
            }

    the editor also has a static constructor that registers the RepositoryItem:

            /// <summary>
            /// Register the <see cref="LookUpEditEx"/> and <see cref="RepositoryItemLookUpEditEx"/>
            /// </summary>
            static LookUpEditEx()
            {
                RepositoryItemLookUpEditEx.RegisterLookUpEditEx();
            }

    and an override of it's own EditorTypeName, that returns "LookUpEdit". 

  • 11/28/2007 10:04 AM In reply to

    Re: RepositoryItem relationship to Editor

    Where in the docs can I find the specifics of this?  From looking at your code, I can't determine if the Editor gets created when the RepositoryItem is instantiated when it is new'd up or if the GridView calls a method on the RepositoryItem when it's particular column has edit focus or if the Editor is instantiated when the column has edit focus which intern instantiates the RepositoryItem.  I'm not sure what the EditorRegistrationInfo.Default.Editors.Add is doing I guess.  To me it appears that this would create multiple registrations of the association between the RepositoryItem and the Editor.  When does the RepositoryItem static contructor get called and when does the Editor static constructor get called?
    <Tsahi Asher> wrote in message news:200843@community.devexpress.com...

     this is all documented in the docs. the RepositoryItem has a static constructor, that is run before the normal constructor, and that invokes the editor. here's how it is in an extension to LookUpEdit i wrote:

            /// <summary>
            /// Register the <see cref="LookUpEditEx"/> and <see cref="RepositoryItemLookUpEditEx"/>
            /// before the main constructor is called.
            /// </summary>
            /// <remarks>Calls <see cref="RegisterLookUpEditEx"/>.</remarks>
            static RepositoryItemLookUpEditEx()
            {
                RegisterLookUpEditEx();
            }

            /// <summary>
            /// Register this repository item and its editor
            /// </summary>
            public static void RegisterLookUpEditEx()
            {
                Image img = null;
                try
                {
                    img = (Bitmap)Bitmap.FromStream(Assembly.GetAssembly(typeof(LookUpEdit))
                        ..GetManifestResourceStream("DevExpress.XtraEditors.Bitmaps256.LookUpEdit.bmp"));
                }
                catch
                {
                }
                EditorRegistrationInfo.Default.Editors.Add(new EditorClassInfo(_editorName,
                    typeof(LookUpEditEx), typeof(RepositoryItemLookUpEditEx), typeof(LookUpEditViewInfo),
                    new ButtonEditPainter(), true, img, typeof(PopupEditAccessible)));
            }

    you also have to override EditorTypeName:

            /// <summary>
            /// Get the name of the associated <see cref="LookUpEditEx"/> editor
            /// </summary>
            /// <value>The name of the editor</value>
            public override string EditorTypeName
            {
                get
                {
                    return _editorName; //_editorName=="LookUpEditEx"
                }
            }

    the editor also has a static constructor that registers the RepositoryItem:

            /// <summary>
            /// Register the <see cref="LookUpEditEx"/> and <see cref="RepositoryItemLookUpEditEx"/>
            /// </summary>
            static LookUpEditEx()
            {
                RepositoryItemLookUpEditEx.RegisterLookUpEditEx();
            }

    and an override of it's own EditorTypeName, that returns "LookUpEdit". 



    http://community.devexpress.com//forums/p/59382/200843.aspx#200843

Page 1 of 1 (3 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED