using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Control.ControlCollection t = this.Controls;//Controls foreach (Control item in t) { if (item.GetType().Name.Equals("TextBox")) { string[] str = item.Name.Split('_'); if (str.Length > 1) { item.Text = str[1]; } } if (item is TextBox) { string[] str = item.Name.Split('_'); if (str.Length > 1) { item.Text = str[1]; } } if (item is Button) { string[] str = item.Name.Split('_'); if (str.Length > 1) { item.Text = str[1]; } } } } } }


浙公网安备 33010602011771号