登录社区:用户名: 密码: 忘记密码 网页功能:加入收藏 设为首页 网站搜索  

文档

下载

图书

论坛

安全

源码

硬件

游戏
首页 | 信息 | 空间 | VB | VC | Delphi | Java | Flash | 补丁 | 控件 | 安全 | 黑客 | 电子书 | 笔记本 | 手机 | MP3 | 杀毒 | QQ群 | 产品库 | 分类信息 | 编程网站
  立华软件园 - Visual Basic 专区 - 技术文档 - C#.Net 技术文章 | VB源代码 | 电子图书 | VB网站 | 相关下载 | 在线论坛 | QQ群组 | 搜索   
 VB技术文档
  · 窗体界面
  · 系统控制
  · VB.Net
  · 多媒体
  · 网络编程
  · API函数
  · 游戏编程
  · 数据报表
  · 其他文档
 VB源代码
  · 窗体界面
  · 文件目录
  · 多媒体
  · 网络编程
  · 系统API
  · 数据报表
  · 游戏编程
  · VBA办公
  · 其他代码
 VB论坛
  · Visual Basic 讨论区
  · VB.Net 讨论区
  · VB数据库开发讨论区
  · VB系统API讨论区
 其他VB资源
  · VB下载资源
  · VB电子图书
  · VB QQ群组讨论区
  · VB 其他网站资源




关于实现日志的明细保存问题
发表日期:2005-05-29作者:dtqgfnet[转贴] 出处:CSDN  

关于实现日志的明细保存问题
 2005-05-24  与联想桥
思路:
   通过一个自定义控件和全局变量实现对每一步进行详细的日志记录
   通BOTTON的委托关系实现调用自定义控件外部BOTTON的单击事件
下面是一个非常简单的例子,
-----自定义控件
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace ZCGL.BaseClass
{
 /// <summary>
 /// bt
 /// 一个BUTTON按钮
 /// </summary>
 public class bt : System.Windows.Forms.UserControl
 {
        public System.Windows.Forms.Button btC;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public bt()
  {
   // 该调用是 Windows.Forms 窗体设计器所必需的。
   InitializeComponent();

   // TODO: 在 InitializeComponent 调用后添加任何初始化

  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if(components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region 组件设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器
  /// 修改此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
            this.btC = new System.Windows.Forms.Button();
            this.SuspendLayout();
            //
            // btC
            //
            this.btC.Location = new System.Drawing.Point(0, 0);
            this.btC.Name = "btC";
            this.btC.Size = new System.Drawing.Size(72, 24);
            this.btC.TabIndex = 0;
            this.btC.Click += new System.EventHandler(this.btC_Click);
            //
            // bt
            //
            this.Controls.Add(this.btC);
            this.Name = "bt";
            this.Size = new System.Drawing.Size(72, 24);
            this.ResumeLayout(false);

        }
  #endregion
内部单击事件代码
        private void btC_Click(object sender, System.EventArgs e)
        {
         MessageBox.Show("内部BOTTON");
        }
实现动态的BOTTON名称
        public string BtName
        {
            get
            {
               return this.btC.Text;
            }
            set
            {
             this.btC.Text = value;
            }
        }
 }
-----继承后的代码

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace BaseClass
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
        private System.Windows.Forms.Label label1;
        private ZCGL.BaseClass.bt bt1;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
            this.label1 = new System.Windows.Forms.Label();
            this.bt1 = new ZCGL.BaseClass.bt();
            this.SuspendLayout();
            //
            // label1
            //
            this.label1.Location = new System.Drawing.Point(48, 56);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(208, 104);
            this.label1.TabIndex = 0;
            this.label1.Text = "基础类库";
            //
            // bt1
            //
            this.bt1.BtName = "显示";
            this.bt1.Location = new System.Drawing.Point(72, 176);
            this.bt1.Name = "bt1";
            this.bt1.Size = new System.Drawing.Size(72, 24);
            this.bt1.TabIndex = 1;
            this.bt1.Load += new System.EventHandler(this.bt1_Load);
            //
            // Form1
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(292, 273);
            this.Controls.Add(this.bt1);
            this.Controls.Add(this.label1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }
  #endregion

        private void bt1_Load(object sender, System.EventArgs e)
        {
        //增加委托实现调用外部的事件
        this.bt1.btC.Click += new  System.EventHandler(this.bt_Click);
        }
        外部事件
        private void bt_Click(object sender, System.EventArgs e)
        {
            MessageBox.Show("外部BOTTON");
        }
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

 

我来说两句】 【发送给朋友】 【加入收藏】 【返加顶部】 【打印本页】 【关闭窗口
中搜索 关于实现日志的明细保存问题

 ■ [欢迎对本文发表评论]
用  户:  匿名发出:
您要为您所发的言论的后果负责,故请各位遵纪守法并注意语言文明。

关于我们 / 合作推广 / 给我留言 / 版权举报 / 意见建议 / 广告投放 / 友情链接  
Copyright ©2001-2006 Lihuasoft.net webmaster(at)lihuasoft.net
网站编程QQ群   京ICP备05001064号 页面生成时间:0.00199