• 自定义控件


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class TestControl : UserControl
        {
            private string UserName="";
            public TestControl()
            {
                InitializeComponent();
            }
            public TestControl(string uid)
            {
                InitializeComponent();
                UserName = uid;
            }
    
            private void TestControl_Load(object sender, EventArgs e)
            {
                YongHuDA da = new YongHuDA();
                YongHu data = da.Select(UserName);
    
                pictureBox1.BackgroundImage = Image.FromFile(data.Pic);
                pictureBox1.BackgroundImageLayout = ImageLayout.Zoom;
    
                label1.Text = data.Nick;
                label2.Text = data.Qian;
    
                button1.Tag = data.Uid;
            }
    
            private void pictureBox1_Click(object sender, EventArgs e)
            {
                //label1.Text;
                this.ParentForm.Controls["label1"].Text = label1.Text;
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
    
            }
    
           
    
    
    
        }
    }
    

      

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                YongHuDA da = new YongHuDA();
                List<YongHu> list = da.Select();
    
                foreach (YongHu data in list)
                {
                    TestControl ctrl = new TestControl(data.Uid);
                    flowLayoutPanel1.Controls.Add(ctrl);
                }
            }
        }
    }
  • 相关阅读:
    Kafka使用代码设置offset值
    单机wordcount
    队列:队列在线程池等有限资源池中的应用
    栈:如何实现浏览器的前进和后退功能?
    Codeforces Beta Round #57 (Div. 2) E. Enemy is weak
    Codeforces Round #345 (Div. 1) A. Watchmen
    Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun
    zoj4027 Sequence Swapping
    zoj4028 LIS
    zoj 3946 Highway Project
  • 原文地址:https://www.cnblogs.com/kun-boke/p/5885531.html
Copyright © 2020-2023  润新知