茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    c#自定義控件中事件的處理
    來源:易賢網(wǎng) 閱讀:2520 次 日期:2014-08-29 10:07:30
    溫馨提示:易賢網(wǎng)小編為您整理了“c#自定義控件中事件的處理”,方便廣大網(wǎng)友查閱!

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    namespace ClientControl

    {

    //1.定義委托

    public delegate void NewsClickEventHandle(object sender,NewsEventArg args);

    public partial class NewsStage : Control

    {

    //2.定義事件

    public event NewsClickEventHandle NewsClicked;

    private Graphics g;

    private bool isMouseOn = false;

    public NewsStage()

    {

    InitializeComponent();

    //3.事件觸發(fā),這樣少了事件注冊,我們在其他窗體中引用控件時只需要注冊事件和編輯事件處理程序即可,可以對比上一篇博客

    this.Click += new EventHandler(NewsStage_Click);

    this.MouseMove += new MouseEventHandler(NewsStage_MouseMove);

    this.MouseLeave += new EventHandler(NewsStage_MouseLeave);

    }

    void NewsStage_MouseLeave(object sender, EventArgs e)

    {

    isMouseOn = false;

    this.Invalidate();

    }

    void NewsStage_MouseMove(object sender, MouseEventArgs e)

    {

    isMouseOn = true;

    this.Invalidate();

    }

    //新聞被點擊 事件觸發(fā)方法

    void NewsStage_Click(object sender, EventArgs e)

    {

    if (_NewsID>=0&&_NewsTitle!="")

    {

    NewsEventArg myArgs = new NewsEventArg(_NewsID,_NewsTitle);

    NewsClicked(this, myArgs);

    }

    }

    private int _NewsID = 0;

    [Description("新聞ID"), Category("Appearance")]

    public int NewsID

    {

    get { return _NewsID; }

    set

    {

    _NewsID = value;

    this.Invalidate();

    }

    }

    /// <summary>

    /// 新聞標題

    /// </summary>

    private string _NewsTitle = "";

    [Description("新聞標題"), Category("Appearance")]

    public string NewsTitle

    {

    get { return _NewsTitle; }

    set

    {

    _NewsTitle = value;

    this.Invalidate();

    }

    }

    private Color _MouseOnColor = new Color();

    [Description("鼠標劃上的樣色"), Category("Appearance")]

    public Color MouseOnColor

    {

    get { return _MouseOnColor; }

    set

    {

    _MouseOnColor = value;

    }

    }

    protected override void OnPaint(PaintEventArgs pe)

    {

    base.OnPaint(pe);

    g = this.CreateGraphics();

    if (isMouseOn)

    {

    g.DrawString(_NewsTitle, this.Font, new SolidBrush(this._MouseOnColor), new PointF(0, 0));

    }

    else

    {

    g.DrawString(_NewsTitle, this.Font, new SolidBrush(this.ForeColor), new PointF(0, 0));

    }

    }

    protected void Dispose()

    {

    g.Dispose();

    }

    }

    public partial class NewsEventArg : EventArgs

    {

    public int NewsID = 0;

    public string NewsTitle = "";

    public NewsEventArg(int newsID,string newsTitle){

    NewsID = newsID;

    NewsTitle = newsTitle;

    }

    }

    }

    更多信息請查看IT技術(shù)專欄

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機網(wǎng)站地址:c#自定義控件中事件的處理

    2026上岸·考公考編培訓(xùn)報班

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)