组件类属性窗口显示设置
[Browsable(true), Category("Local"), Description("本地IP地址")]
Browsable(true):指定一个事件或者在属性是否显示在属性的窗口中。
Category("Local"):Category 属性 (Property) 在首次被访问时调用该方法以查阅指定类别的本地化名称
Description("本地IP地址"):属性窗口中选项的描述信息。
用法:
[Browsable(true), Category("Local"), Description("本地IP地址")] //在“属性”窗口中显示localHost属性
public string LocalHost
{
get { return localHost; }
set { localHost = value; }
}
private int localPort = 11000;
[Browsable(true), Category("Local"), Description("本地端口号")] //在“属性”窗口中显示localPort属性
public int LocalPort
{
get { return localPort; }
set { localPort = value; }
}
private bool active = false;
[Browsable(true), Category("Local"), Description("激活监听")] //在“属性”窗口中显示active属性
public bool Active
{
get { return active; }
set //该属性读取值
{
active = value;
if (active) //当值为True时
{
OpenSocket(); //打开监听
}
else
{
CloseSocket(); //关闭监听
}
}
}
public string LocalHost
{
get { return localHost; }
set { localHost = value; }
}
private int localPort = 11000;
[Browsable(true), Category("Local"), Description("本地端口号")] //在“属性”窗口中显示localPort属性
public int LocalPort
{
get { return localPort; }
set { localPort = value; }
}
private bool active = false;
[Browsable(true), Category("Local"), Description("激活监听")] //在“属性”窗口中显示active属性
public bool Active
{
get { return active; }
set //该属性读取值
{
active = value;
if (active) //当值为True时
{
OpenSocket(); //打开监听
}
else
{
CloseSocket(); //关闭监听
}
}
}