C#中事件允許一個對象將發生的事件通知其他對象,將發生的事件的事件來源叫發行者,通知其他的對象叫訂閱者,但是訂閱者可以定義也可以不定義(事件發生者也可以是時間的訂閱者)定義事件的步驟:1.定義事件(event關鍵字)2.訂閱事件3.觸發事件下面是一個執行個體的應用using System;using System.Collections.Generic;using System.Text;namespace Person{ class User { ///
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace DelegateText{ class TextDelegate { //定義委託 public delegate void DelegateLogin(string name, string password); //定義事件 public
public partial class Form1 : Form { bool MouseIsDown = false; Rectangle MouseRect = Rectangle.Empty; public Form1() { InitializeComponent(); this.MouseDown += new MouseEventHandler(Form1_MouseDown); this.MouseMove += new
OutLookQQ風格控制項C#樣本public partial class OutLookExUI : UserControl { public InnerOutLookTreeClass OutLookTree = new InnerOutLookTreeClass(); public Panel MainPanel = new Panel(); public OutLookExUI() {
程式碼 介紹:在我當前的項目中,客戶希望管理者可以在網站上發布檔案,客戶的文章(不管是改動或添加什麼)都可以將改過的版本上傳回網站。然後,管理員可以瀏覽課餘關於文章修改的摘要,允許他可以批准或否定。儘管我開始以為會很難實現,翻了一些資料,發現除了對單詞“跟蹤變化”這一特性之外,將幾個文檔合并為一個是可以做到的,這樣一個文檔裡的所有變化都是允許的。當然可以通過VBA來應用該方法;.net也可以實現。解決方案:為了做到這些,我用Visual Studio .NET 2003建立了一個C#
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace TreeViewTest{ public partial class Form1 : Form { public Form1()