Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Embed custom controls
posted

Hi, team

I have a question about embed custom controls. And here it is:

I got a custom control CCalendarCombo which inherits from UserControl. It shows in screenshot one.

    public partial class CCalendarCombo : UserControl
    {
      
        public CCalendarCombo()
        {
            InitializeComponent();
            this.commTextEditor.ContextMenuStrip = new ContextMenuStrip();
            this.commTextEditor.ContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.back,
            this.cut,
            this.copy,
            this.past,
            this.del,
            this.selAll});
            this.commTextEditor.AlwaysInEditMode = true;
            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(228)))), ((int)(((byte)(237)))), ((int)(((byte)(241)))));
        }
        #endregion
        }

When I read about this ariticle below, I realized that I need to use ControlContainerEditor.

http://help.infragistics.com/Help/Doc/WinForms/2012.2/CLR4.0/HTML/WinControlContainerEditor_Embed_Any_Control_within_WinGrid_Cell_using_ControlContainerEditor_Object.html

And here is what the ControlContainerEditor source.

namespace BaseControl
{
    public partial class CEditor  : ControlContainerEditor 
    {
        private CCalendarCombo cCalendarCombo;
        public CEditor(CCalendarCombo ccb)
        {
            this.cCalendarCombo = ccb;
            this.EditingControl = ccb;
        }
        protected override object RendererValue
        {
            get
            {
                return this.cCalendarCombo.value;
            }
            set
            {
                this.cCalendarCombo.value = (string)value;
            }
        }
    }
}

In Form1, I used it like this(which is used in the winGrid):

CEditor editor = new CEditor(this.cCalendarCombo1);
columns[OUTCOMEDATE].Editor = editor;
columns[OUTCOMEDATE].Width = 200;

But what it implements is like the screenshot below.

In the second one, I want to click the button to show the calender, but it gives no response.

And the third one, when I input some date value in the controls, it doesn't show the value.

Last one, when focus in the controls it shows the value but when left focus it just like the second one.

Any idea how did this happen? Hopefully you'll help me with that.

Thanks for your concern.