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];
                    }
                }

            }
        }
    }
}

posted on 2020-08-07 13:19  silverTiFa  阅读(118)  评论(0)    收藏  举报