构建 Windows 客户端应用与 GDI+ 绘图基础
1. 用户控件设计要点
用户控件本质上是带有一些附加功能的控件,在设计时需要考虑一些特定问题。
- 初始化问题 :初始化用户控件可能会遇到与某些示例(如 FolderTree 示例)相同的问题。在设计用户控件时,要避免访问其他开发者使用该控件时可能无法访问的数据存储。
- 属性应用 :与控件创建类似,用户控件也可以应用属性。当控件放置在设计器上时,其公共属性和方法会显示在属性窗口中。例如,对于地址用户控件,给地址属性添加 Category、Description 和 DefaultValue 属性是个好主意。可以创建一个新的 AddressData 类别,默认值都设为 “”。以下是应用这些属性到 AddressLine1 属性的示例代码:
[Category("AddressData"),
Description("Gets or sets the AddressLine1 value"),
DefaultValue("")]
public string AddressLine1
{
get{return txtAddress1.Text;}
set{
if(txtAddress1.Text != value)
{
txtAddress1.Text = value;
if(AddressLine1Changed != null)
AddressLine1Chan
超级会员免费看
订阅专栏 解锁全文
1410

被折叠的 条评论
为什么被折叠?



