c#,winform,UserContrl,用户控件开发,窗体

 66.JPG
用户控件效果如上图
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace WindowsControlLibrary1
{
    
public partial class UserControl1 : UserControl
    
{
        
public event EventHandler AddressLine1Changed;
        
public event EventHandler AddressLine2Changed;
        
public event EventHandler ZoneChanged;
        
public event EventHandler NumberChanged;

        
private void TextBoxControls_TextChanged(object sender, EventArgs e)
        
{
            
switch (((TextBox)sender).Name)
            
{
                
case "txtAddress1":
                    
if (AddressLine1Changed != null)
                    
{
                        AddressLine1Changed(
this, EventArgs.Empty);
                    }

                    
break;
                
case "txtAddress2":
                    
if (AddressLine2Changed != null)
                        AddressLine2Changed(
this, EventArgs.Empty);
                    
break;
                
case "txtZone":
                    
if (ZoneChanged != null)
                        ZoneChanged(
this, EventArgs.Empty);
                    
break;
                
case "txtNumber":
                    
if (NumberChanged != null)
                        NumberChanged(
this, EventArgs.Empty);
                    
break;
            }

        }

        [Category(
"NumberData"), DescriptionAttribute("Gets or sets the Number value"), DefaultValue("")]
        
public string Number
        
{
            
get return this.txtNumber .Text; }
            
set
            
{
                
if (txtNumber.Text != value)
                
{
                    txtNumber.Text 
= value;
                    
if (NumberChanged != null)
                        NumberChanged(
this, PropertyChangedEventArgs.Empty);
                }

            }

        }

        [Category(
"AddressData"), DescriptionAttribute("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)
                        AddressLine1Changed(
this, PropertyChangedEventArgs.Empty);
                }

            }

        }

        [Category(
"AddressData"), DescriptionAttribute("Gets or sets the AddressLine2 value"), DefaultValue("")]
        
public string AddressLine2
        
{
            
get return txtAddress2.Text; }
            
set
            
{
                
if (txtAddress2.Text != value)
                
{
                    txtAddress2.Text 
= value;
                    
if (AddressLine2Changed != null)
                        AddressLine2Changed(
this, PropertyChangedEventArgs.Empty);
                }

            }

        }

        [Category(
"ZoneData"), DescriptionAttribute("Gets or sets the Zone value"), DefaultValue("")]
        
public string Zone
        
{
            
get return txtZone.Text; }
            
set
            
{
                
if (txtZone.Text != value)
                
{
                    txtZone.Text 
= value;
                    
if (ZoneChanged!= null)
                        ZoneChanged(
this, PropertyChangedEventArgs.Empty);
                }

            }

        }

        
        
        
public UserControl1()
        
{
            InitializeComponent();
        }

    }

}

posted on 2008-05-25 15:04 virus 阅读(655) 评论(0)  编辑 收藏 所属分类: .net 2.0


标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-05-26 23:14 编辑过
 
 
<2008年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

导航

统计

公告

大家快乐就好,可不要因为工作累坏身体啊,身体是工作的本钱啊!
任何一个傻瓜都能写出计算机可以理解的程序,只有写出人类容易理解的程序才是优秀的程序员。
我的MSN:jorden008@hotmail.com

与我联系

搜索

 

常用链接

留言簿(9)

我参与的团队

我的标签

随笔分类(132)

随笔档案(149)

文章分类(27)

收藏夹(1)

.NET 2.0 Dispose

.NET 2.0 Socket

.NET WinForm控件开发

.NET 加密解密

.NET 序列化

.NET 自定义异常

.NET安装部署

.NET技巧

.NET开源项目

.NET学习资源

ACM题库

ActiveX插件

ASP.NET 2.0

ASP.NET 2.0 Cache

ASP.NET 2.0 GridView

ASP.NET 2.0的用户密码加密(注册登录)

ASP.NET 3.5

ASP.NET AJAX

ASP.NET LINQ

ASP.NET MVC

ASP.NET Repeater

ASP.NET ViewState

ASP.NET Webservice

c# 3.0

c# Dllimport c++

c# ORM

c# WndProc

c# 面向接口设计

c#+winform自动升级

c#操作数据库