五块五卖你了 发表于 2013-1-2 23:11:21

C#/.NET 抽象文本框click事件

<div id="cnblogs_post_body"><div class="cnblogs_code" >http://images.cnblogs.com/OutliningIndicators/ContractedBlock.gifhttp://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gifView Code <div id="cnblogs_code_open_b22a5b67-df7a-4851-9c4a-65572feca763" class="cnblogs_code_hide"> 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Windows.Forms; 9 10 namespace WindowsFormsApplication111 {12   public partial class Form2 : Form13     {14         public Form2()15       {16             InitializeComponent();17             foreach (var item in this.Controls)18             {19               TextBox tbox = (TextBox)item;20               if (tbox != null)21                 {22                     tbox.Click += new EventHandler(eventText);23                 }24             }25       }26 27         void eventText(object sender, EventArgs e)28       {29             TextBox tbox = (TextBox)sender;30             MessageBox.Show(tbox.Name);31       }32     }33 }
页: [1]
查看完整版本: C#/.NET 抽象文本框click事件