Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I've created my custom control. It has a property that is called "Tab." This property adds a collection of "FloorsInformation" controls that are inherited from "DockContainerItem" class to my custom control.
Figure 1[^]
Now, I want to add "FloorsInformation" controls to my custom control after click the "OK" button of the Tab "CollectionEditor" window.
Figure 2[^]
I have "AddTabs" method for doing that. However, I can't call it in the right place. I must call "AddTabs" method in "set accessor" of the "Tab" property, but it never occurs.
I also can call this method from "get accessor" of the "Tab" property, but calling this method in "get accessor" of the "Tab" property will result in an error, because the program access to the "get accessor" of the "Tab" property continuously.
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
[ToolboxItem(true), ToolboxBitmap(typeof(ToolboxIconResourceFinder), "FloorsGrouping.bmp")]
[DisplayName("Floors Group")]
[Editor("WindowsFormsControlLibrary2.FloorsGrouping, WindowsFormsControlLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=197889249da45bfc", typeof(UITypeEditor))]
[Description("Floorssssssss")]
[Category("Saino")]
[DefaultProperty("Text")]
[DesignerCategory("Component")] //Form //Designer //Empty String ("")
public partial class FloorsGrouping : Bar
{
    private Tabs tabs = new Tabs();
 
    public FloorsGrouping()
    {
        InitializeComponent();
        this.AutoHide = true;
    }
 
    [Category("Data")]
    [DisplayName("Tabs")]
    [Description("Tabsssssssssssss")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [Editor(typeof(ItemsCollectionEditor), typeof(UITypeEditor))]
    public Tabs Tab
    {
        get
        {
            //AddTabs();
            return tabs;
        }
        //set
        //{
            //AddTabs();
        //}
    }
 
    public void AddTabs()
    {
        foreach (DockContainerItem dciItem in Tab)
        {
            if (!Parent.Controls.ContainsKey(dciItem.Name))
            {
                Items.Add(dciItem);
            }
        }
    }
}
 
[DisplayName("Floors Information")]
[Description("Floors Informationnnnnnnnnnnnnnnn")]
[DefaultProperty("Text")]
[DesignerCategory("Component")]
[ToolboxItem(false)]
public class FloorsInformation : DockContainerItem
{
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;
 
    private SimilarFloorsInformation similarFloorsInformation = new SimilarFloorsInformation();
    private AllFloorsInformation allFloorsInformation = new AllFloorsInformation();
    private string text = "Floors Information";
 
    public FloorsInformation()
    {
 
    }
 
    [Category("Data")]
    [DisplayName("Similar Floors Panel")]
    [Description("Similar Floors Panellllllllllllllllllll")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public SimilarFloorsInformation SimilarFloorsInfo
    {
        get
        {
            return similarFloorsInformation;
        }
        set
        {
            similarFloorsInformation = value;
        }
    }
 
    [Category("Data")]
    [DisplayName("All Floors Group")]
    [Description("All Floors Groupppppppppppppp")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public AllFloorsInformation AllFloorsInfo
    {
        get
        {
            return allFloorsInformation;
        }
        set
        {
            allFloorsInformation = value;
        }
    }
 
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }
}
 
public class Tabs : CollectionBase
{
    public FloorsInformation this[int intIndex]
    {
        get
        {
            return (FloorsInformation)InnerList[intIndex];
        }
        set
        {
            InnerList[intIndex] = value;
        }
    }
 
    public int Add(FloorsInformation finfItemType)
    {
        return InnerList.Add(finfItemType);
    }
 
    public bool Contains(FloorsInformation finfItemType)
    {
        return InnerList.Contains(finfItemType);
    }
 
    public void Remove(FloorsInformation finfItemType)
    {
        InnerList.Remove(finfItemType);
    }
 
    public void Insert(int intIndex, FloorsInformation finfItemType)
    {
        InnerList.Insert(intIndex, finfItemType);
    }
 
    public FloorsInformation[] GetValues()
    {
        FloorsInformation[] finfItemType = new FloorsInformation[InnerList.Count];
        InnerList.CopyTo(0, finfItemType, 0, InnerList.Count);
        return finfItemType;
    }
}
By the way, I can call this method in "SetItems" overrode method of the "ItemsCollectionEditor" class that is inherited from "CollectionEditor" class; nevertheless, I can't access to "AddTabs" method without create a new instance of my custom control class. If I create a new instance of my custom control, "AddTabs" method applies changes on a new control of my custom control and not on the current added custom control in the WinForm.
public class ItemsCollectionEditor : CollectionEditor
{
    private Type[] typItems;
 
    public ItemsCollectionEditor(Type typItem)
        : base(typItem)
    {
        typItems = new Type[] { typeof(FloorsInformation) };
    }
 
    protected override Type[] CreateNewItemTypes()
    {
        return typItems;
    }
 
    protected override CollectionForm CreateCollectionForm()
    {
        CollectionForm collectionForm = base.CreateCollectionForm();
        collectionForm.Text = "Tabs Collection Editor";
        return collectionForm;
        //return base.CreateCollectionForm();
    }
 
    protected override object SetItems(object editValue, object[] value)
    {
        return base.SetItems(editValue, value);
    }
}
What must I do for achieve to my goal?
Posted 21-Nov-12 2:24am
MRS1989677
Edited 21-Nov-12 19:22pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 22 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100