- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我将创建的自定义控件添加到新的 Windows 窗体中,并通过“Tabs”属性向其添加一些 Tab。但是,当我从 Windows 窗体中删除我的自定义控件时,不会删除“Tabs”属性的元素。请参阅下图了解更多信息:
图 1 - 我的自定义控件“Tabs”属性及其集合编辑器
[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")]
//[DefaultEvent("")]
[DefaultProperty("Text")]
[DesignerCategory("Component")] //Form //Designer //Empty String ("")
public partial class FloorsGrouping : Bar
{
private static Font fntDefaultFont = SystemFonts.DefaultFont;
private static string strDefaultAccessibleDescription = "";
private static string strDefaultAccessibleName = "";
private bool canDockBottom = false;
private bool canDockTop = false;
private bool fadeEffect = true;
private int selectedDockTab = 0;
private eDotNetBarStyle style = eDotNetBarStyle.StyleManagerControlled;
private string text = "Floors Grouping";
private FloorsInformation floorsInformation = new FloorsInformation();
private Tabs tabs = new Tabs();
private SupportedLanguages language = SupportedLanguages.English;
private Styles groupingStyles = Styles.Classic;
public FloorsGrouping()
{
InitializeComponent();
ResetFont();
ResetAccessibleDescription();
ResetAccessibleName();
}
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
Tab.Clear();
Tab.RemoveRange(0, Tab.Count);
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private new void ResetFont()
{
Font = fntDefaultFont;
}
private new bool ShouldSerializeFont()
{
return !Font.Equals(fntDefaultFont);
}
[Category("Data")]
[DisplayName("Tabs")]
[Description("Tabsssssssssssss")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor(typeof(ItemsCollectionEditor), typeof(UITypeEditor))]
//[Editor(typeof(ItemsCollectionEditor<SimilarFloorsInformation>), typeof(UITypeEditor))]
//[Editor(typeof(CollectionEditor), typeof(UITypeEditor))]
public Tabs Tab
{
get
{
return tabs;
}
}
[Category("Behavior")]
[DisplayName("ContainerControl")]
[Description("It indicates container control high lighter is bound to. It should be set to parent form.")]
//[DefaultValue("")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Browsable(false), ReadOnly(true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public Control ContainerControl
{
get { return hltMain.ContainerControl; }
private set { hltMain.ContainerControl = this; }
}
protected override void OnParentChanged(EventArgs e)
{
ContainerControl = this;
}
protected override void OnCreateControl()
{
base.OnCreateControl();
}
protected override void OnControlRemoved(ControlEventArgs e)
{
//Tab.RemoveRange(0, tabs.Count);
//Parent.Refresh();
base.OnControlRemoved(e);
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
}
}
[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()
{
}
[Browsable(false), ReadOnly(true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public new bool AutoCollapseOnClick
{
get { return base.AutoCollapseOnClick; }
}
[Browsable(false), ReadOnly(true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public new Control Control
{
get { return base.Control; }
}
public new string Text
{
get
{
return text;
}
set
{
text = value;
}
}
[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 new void Clear()
{
InnerList.Clear();
}
public bool Contains(FloorsInformation finfItemType)
{
return InnerList.Contains(finfItemType);
}
public void Remove(FloorsInformation finfItemType)
{
InnerList.Remove(finfItemType);
}
public new void RemoveAt(int intIndex)
{
InnerList.RemoveAt(intIndex);
}
public void RemoveRange(int intIndex, int intCount)
{
InnerList.RemoveRange(intIndex, intCount);
}
public void Insert(int intIndex, FloorsInformation finfItemType)
{
InnerList.Insert(intIndex, finfItemType);
}
public void Reverse()
{
InnerList.Reverse();
}
public void Reverse(int intIndex, int intCount)
{
InnerList.Reverse(intIndex, intCount);
}
public int IndexOf(FloorsInformation finfItemType)
{
return InnerList.IndexOf(finfItemType);
}
public void AddRange(FloorsInformation[] finfItemType)
{
InnerList.AddRange(finfItemType);
}
public FloorsInformation[] GetValues()
{
FloorsInformation[] finfItemType = new FloorsInformation[InnerList.Count];
InnerList.CopyTo(0, finfItemType, 0, InnerList.Count);
return finfItemType;
}
protected override void OnInsert(int intIndex, object objValue)
{
base.OnInsert(intIndex, objValue);
}
protected override void OnClear()
{
base.OnClear();
}
}
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();
}
}
最佳答案
我找到了解决方案。为了在从其父控件(Windows 窗体)中删除自定义控件后自动删除“Tabs”属性成员,必须对从“Bar”类继承的“FloorsGrouping”类的“Dispose”方法应用一些更改。请参阅以下必须更改的代码行:
protected override void Dispose(bool disposing)
{
Tab.Clear();
Tab.RemoveRange(0, Tab.Count);
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
if (Tab.Count > 0)
{
foreach (FloorsInformation floorsInformation in Tab)
{
floorsInformation.Dispose();
}
}
base.Dispose(disposing);
}
关于c# - 在设计模式下从窗体中删除自定义控件后清除自定义控件属性的 InnerList 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13044221/
对于一个科学实验,我写了一个turtle.py ,它会打开一个 800x480 的窗口并绘制一个缓慢增长的黑点。 turtle.py以 C:\Users\kaza>python C:\Users\ka
我开发了一个 swing 应用程序,但每次运行应用程序时都会打开一个新窗口。我希望如果一个窗口已经打开,则其他窗口不允许打开。 最佳答案 Here是一个 Java 单一应用实例的例子: A singl
有没有办法检测主进程中 Electron 的结构? process.platform 似乎也在 x64 机器上返回 win32,我没有在文档中找到任何获取架构的选项。 最佳答案 你试过 process
public short[] HanningWindow(short[] signal_in ,int pos ,int size) { for (int i= pos; i < pos+si
我有一个具有这些属性的 Electron 窗口: mainWindow = new BrowserWindow({ width: 800, height: 600, title: "Aqu
我有一个 Ubuntu 工作站,我正在尝试引导一个 Windows 节点。 Windows 节点在端口 2222 上打开了 ssh。我一直在关注 http://docs.opscode.com/plu
我是一名优秀的程序员,十分优秀!