• 自定义控件


    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);
                }
            }
        }
    }
  • 相关阅读:
    用MFC(C++)实现拼音搜索
    MFC里ON_COMMAND_RANGE消息映射的ID问题
    01:MFC应用程序编程
    MFC笔记(DN)
    linuxmint系统定制与配置(2)-输入法
    linuxmint系统定制与配置(3)-字体
    linuxmint系统定制与配置(1)-系统初始配置
    笔记-读官方Git教程(2)~安装与配置
    笔记-读官方Git教程(1)~认识Git
    Python中多层List展平为一层
  • 原文地址:https://www.cnblogs.com/kun-boke/p/5885531.html
Copyright © 2020-2023  润新知