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

Creating a Composite Control

Last post 8/21/2008 5:56 PM by Trevor Westerdahl. 11 replies.
Page 1 of 1 (12 items)
Sort Posts:
Previous Next
  • 8/19/2008 12:11 PM

    Creating a Composite Control

     I want to create a new control which is a composite of other controls.  I want my new control to contain a LookUpEditor and one or more LabelControls that will show the details of the record that the user selected.

    What container should I use to hold the controls (XtraUserControl?)?  How do I create the properties that are needed to set dataSource, displayMember, editValue and valueMember.

    Are there any examples of what I am trying to do?

  • 8/19/2008 4:51 PM In reply to

    Re: Creating a Composite Control

    What I do is create a usercontrol. I then populate the control surface exactly the same way as I do with any other form.

    I then use the created usercontrol by adding it to a tab page but you could also add it to a panel control and dock it I guess..

    This can be found as an example in the NavBarControl or alternative to mdi example in the documentation - can't remember where exactly.

    Glen Harvy.
  • 8/20/2008 9:16 AM In reply to

    Re: Creating a Composite Control

     You have accurately described what I am trying to do. But my question is this.

    How do I define my usercontrol so that I can set the properties of the contained LookUpEditor?  How do I create the properties that are needed to set dataSource, displayMember, editValue and valueMember?

  • 8/20/2008 11:24 AM In reply to

    Re: Creating a Composite Control

     Have you tried changing the LookUpEditor object's Modifier from private to public?  This works for some controls.

     

  • 8/20/2008 11:39 AM In reply to

    Re: Creating a Composite Control

    If, what Robert Chaffe suggests, does not publish your LookUpEditor, you can add a property to your UserControl with "getter and setter" and then you should see your LookUpEditor in the Designer.
     
    I tried it with a ListBox at it does what you want:
     

    public ListBox ListBox

    {

    get { return this.ListBoxTest; }

    set { this.ListBoxTest = value; }

    }

     

    <Richard Askwith> schrieb im Newsbeitrag news:231783@community.devexpress.com...

     You have accurately described what I am trying to do. But my question is this.

    How do I define my usercontrol so that I can set the properties of the contained LookUpEditor?  How do I create the properties that are needed to set dataSource, displayMember, editValue and valueMember?



    http://community.devexpress.com//forums/p/68090/231783.aspx#231783

  • 8/20/2008 1:37 PM In reply to

    Re: Creating a Composite Control

    This is what I think you need (assuming the name of your LookupEdit is lookupEdit1):
     

    [DefaultValue((string)null),

    #if DXWhidbey

     AttributeProvider(typeof(IListSource))]

    #else

    TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design")]
    #endif

    public object DataSource {
        get
    { return lookupEdit1.DataSource; }
        set
    { lookupEdit1.DataSource = value; }

    }

     [DefaultValue((string)null), Editor(ControlConstants.DataMemberEditor, typeof(System.Drawing.Design.UITypeEditor))]

    public string DataMember {

        get { return lookupEdit1.DataMember; }

        set { lookupEdit1.DataMember = value; }

    }

     

    "Richard Askwith" wrote in message news:231649@community.devexpress.com...

     I want to create a new control which is a composite of other controls.  I want my new control to contain a LookUpEditor and one or more LabelControls that will show the details of the record that the user selected.

    What container should I use to hold the controls (XtraUserControl?)?  How do I create the properties that are needed to set dataSource, displayMember, editValue and valueMember.

    Are there any examples of what I am trying to do?



    http://community.devexpress.com//forums/p/68090/231649.aspx#231649

    Trevor Westerdahl - DX Squad
    BLOG: http://trevorunlocked.blogspot.com/
  • 8/20/2008 2:31 PM In reply to

    Re: Creating a Composite Control

     Thank you! 

    You are putting me on a track that feels much more comfortable.   I definitely prefer encapsulating everything within the container and exposing only those properties that are needed.

    I will give it a try and report back with my results.

  • 8/21/2008 4:06 PM In reply to

    Re: Creating a Composite Control

    Did it work?
    "Richard Askwith" wrote in message news:231844@community.devexpress.com...

     Thank you! 

    You are putting me on a track that feels much more comfortable.   I definitely prefer encapsulating everything within the container and exposing only those properties that are needed.

    I will give it a try and report back with my results.



    http://community.devexpress.com//forums/p/68090/231844.aspx#231844

    Trevor Westerdahl - DX Squad
    BLOG: http://trevorunlocked.blogspot.com/
  • 8/21/2008 5:02 PM In reply to

    Re: Creating a Composite Control

     For the most part, yes.

    I was able to successfully create properties that connect to the dataSource, displayMember and valueMember of my contained LookUpEdit. 

    However, I am still struggling with the editValue property.  I am still trying to figure out what attributes to give it so that I can have that nice popup that appears when I set editValue in the LookUpEdit control.

  • 8/21/2008 5:18 PM In reply to

    Re: Creating a Composite Control

    Try this:
     

    [Description("Gets or sets the editor's value."), Bindable(true), Localizable(true), Category(CategoryName.Data),

    RefreshProperties(RefreshProperties.All), DefaultValue(null),

    Editor(typeof(DevExpress.Utils.Editors.UIObjectEditor), typeof(System.Drawing.Design.UITypeEditor)),

    TypeConverter(typeof(DevExpress.Utils.Editors.ObjectEditorTypeConverter))]

    public object EditValue {

    get { return lookupEdit1.EditValue; }

    set { lookupEdit1.EditValue = value;}
    }

     

     

    "Richard Askwith" wrote in message news:231971@community.devexpress.com...

     For the most part, yes.

    I was able to successfully create properties that connect to the dataSource, displayMember and valueMember of my contained LookUpEdit. 

    However, I am still struggling with the editValue property.  I am still trying to figure out what attributes to give it so that I can have that nice popup that appears when I set editValue in the LookUpEdit control.



    http://community.devexpress.com//forums/p/68090/231971.aspx#231971

    Trevor Westerdahl - DX Squad
    BLOG: http://trevorunlocked.blogspot.com/
  • 8/21/2008 5:37 PM In reply to

    Re: Creating a Composite Control

    Yahoo!!!!   It worked like a charm.  Thank you!

    Now, where would I have gone to figure all of that out by myself?

     

    Trevor Westerdahl:

    Try this:
     

    [Description("Gets or sets the editor's value."), Bindable(true), Localizable(true), Category(CategoryName.Data),

    RefreshProperties(RefreshProperties.All), DefaultValue(null),

    Editor(typeof(DevExpress.Utils.Editors.UIObjectEditor), typeof(System.Drawing.Design.UITypeEditor)),

    TypeConverter(typeof(DevExpress.Utils.Editors.ObjectEditorTypeConverter))]

    public object EditValue {

    get { return lookupEdit1.EditValue; }

    set { lookupEdit1.EditValue = value;}
    }

     

     

     

  • 8/21/2008 5:56 PM In reply to

    Re: Creating a Composite Control

    > Yahoo!!!!   It worked like a charm.  Thank you!
    > Now, where would I have gone to figure all of that out by myself?
     
    Buy/pay for the source code and use it as a resource...Smile emoticon
     
     
    Trevor Westerdahl - DX Squad
    BLOG: http://trevorunlocked.blogspot.com/
Page 1 of 1 (12 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED