C#组件编程

来源:互联网 发布:东华理工行知分院官网 编辑:程序博客网 时间:2024/06/16 03:23

1)常用属性标签说明

1.Category:设置属性分组

2.Description:属性或事件的说明

3.ReadOnly:设置组件或属性是否只读

2)集合属性的设置:一定要继承System.Collections.CollectionBase

   private ListItemCollection _ValueList = new ListItemCollection();
public ListItemCollection ValueList
        
{
            
get return _ValueList; }
            
set { _ValueList = value; }
        }



/// <summary>
    
/// 单项
    
/// </summary>

    public class ListItem
    
{
        
public ListItem()
        
{
            
//
        }


        
private string _Text = "";
        
private string _Value = "";

        [CategoryAttribute(
"系统"),
        ReadOnlyAttribute(
false),
        DescriptionAttribute(
"子项文本")]
        
public string Text
        
{
            
get return _Text; }
            
set { _Text = value; }
        }


        [CategoryAttribute(
"系统"),
        ReadOnlyAttribute(
false),
        DescriptionAttribute(
"子项数值")]
        
public string Value
        
{
            
get return _Value; }
            
set { _Value = value; }
        }

    }


    
public class ListItemCollection : System.Collections.CollectionBase
    
{
        
public ListItemCollection()
        
{
            
//
        }


        
public void Add(ListItem _LI)
        
{
            
base.InnerList.Add(_LI);
        }


        
public void Remove(ListItem _LI)
        
{
            
base.InnerList.Remove(_LI);
        }


        
public ListItem this[int index]
        
{
            
set
            
{
                InnerList[index] 
= value;
            }

            
get
            
{
                
return (ListItem)InnerList[index];
            }

        }

    }

原创粉丝点击