如和在自定义控件添加ITEM属性
如题
------解决方案--------------------在封装类中做一个public的item集合成员,即可!
------解决方案--------------------由ComboBox继承一个子类
在子类里添加所需的属性.
------解决方案-------------------- //****************************
//www.21centuryit.com *
//---------------------------*
//用户自定义控件,出自MSDN *
//****************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Drawing;
using System.Data;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
// This sample demonstrates the use of various attributes for
// authoring a control.
namespace AttributesDemoControlLibrary
{
// This is the event handler delegate for the ThresholdExceeded event.
public delegate void ThresholdExceededEventHandler(ThresholdExceededEventArgs e);
// This control demonstrates a simple logging capability.
[ComplexBindingProperties( "DataSource ", "DataMember ")]
[DefaultBindingProperty( "TitleText ")]
[DefaultEvent( "ThresholdExceeded ")]
[DefaultProperty( "Threshold ")]
[HelpKeywordAttribute(typeof(UserControl))]
[ToolboxItem( "System.Windows.Forms.Design.AutoSizeToolboxItem,System.Design ")]
public class AttributesDemoControl : UserControl
{
// This backs the Threshold property.
private object thresholdValue;
// The default fore color value for DataGridView cells that
// contain values that exceed the threshold.
private static Color defaultAlertForeColorValue = Color.White;
// The default back color value for DataGridView cells that
// contain values that exceed the threshold.
private static Color defaultAlertBackColorValue = Color.Red;
// The ambient color value.
private static Color ambientColorValue = Color.Empty;
// The fore color value for DataGridView cells that
// contain values that exceed the threshold.
private Color alertForeColorValue = defaultAlertForeColorValue;
// The back color value for DataGridView cells that
// contain values that exceed the threshold.
private Color alertBackColorValue = defaultAlertBackColorValue;
// Child controls that comprise this UserControl.
private TableLayoutPanel tableLayoutPanel1;
private DataGridView dataGridView1;
private Label label1;
// Required for designer support.
private System.ComponentModel.IContainer components = null;
// Default constructor.
public AttributesDemoControl()
{
InitializeComponent();
}
[Category( "Appearance ")]
[Description( "The title of the log data. ")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Localizable(true)]
[HelpKeywordAttribute( "AttributesDemoControlLibrary.AttributesDemoControl.TitleText ")]
public string TitleText
{
get
{
return this.label1.Text;
}
set
{
this.label1.Text = value;