zoukankan      html  css  js  c++  java
  • 自定义控件

    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);
                }
            }
        }
    }
  • 相关阅读:
    【学习笔记】整除分块
    【Luogu P2201】【JZOJ 3922】数列编辑器
    【SSL1786】麻将游戏
    【SSL2325】最小转弯问题
    【JZOJ 3910】Idiot 的间谍网络
    【Luogu P1879】[USACO06NOV]玉米田Corn Fields
    【JZOJ 3909】Idiot 的乘幂
    【JZOJ 3918】蛋糕
    【Luogu P3174 】[HAOI2009]毛毛虫
    【SSL1194】最优乘车
  • 原文地址:https://www.cnblogs.com/kun-boke/p/5885531.html
Copyright © 2011-2022 走看看