1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApplication1
  12. {
  13. public partial class TestControl : UserControl
  14. {
  15. private string UserName="";
  16. public TestControl()
  17. {
  18. InitializeComponent();
  19. }
  20. public TestControl(string uid)
  21. {
  22. InitializeComponent();
  23. UserName = uid;
  24. }
  25.  
  26. private void TestControl_Load(object sender, EventArgs e)
  27. {
  28. YongHuDA da = new YongHuDA();
  29. YongHu data = da.Select(UserName);
  30.  
  31. pictureBox1.BackgroundImage = Image.FromFile(data.Pic);
  32. pictureBox1.BackgroundImageLayout = ImageLayout.Zoom;
  33.  
  34. label1.Text = data.Nick;
  35. label2.Text = data.Qian;
  36.  
  37. button1.Tag = data.Uid;
  38. }
  39.  
  40. private void pictureBox1_Click(object sender, EventArgs e)
  41. {
  42. //label1.Text;
  43. this.ParentForm.Controls["label1"].Text = label1.Text;
  44.  
  45. }
  46.  
  47. private void button1_Click(object sender, EventArgs e)
  48. {
  49.  
  50. }
  51.  
  52. }
  53. }

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApplication1
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private void Form1_Load(object sender, EventArgs e)
  21. {
  22. YongHuDA da = new YongHuDA();
  23. List<YongHu> list = da.Select();
  24.  
  25. foreach (YongHu data in list)
  26. {
  27. TestControl ctrl = new TestControl(data.Uid);
  28. flowLayoutPanel1.Controls.Add(ctrl);
  29. }
  30. }
  31. }
  32. }

C#窗体自定义控件的更多相关文章

  1. C#窗体 自定义控件

    1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Dr ...

  2. WPF自定义控件与样式(13)-自定义窗体Window & 自适应内容大小消息框MessageBox

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: 自定义 ...

  3. 【转】WPF自定义控件与样式(13)-自定义窗体Window & 自适应内容大小消息框MessageBox

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等. 本文主要内容: 自定义Window窗体样式: 基于自定义窗体实现自定义MessageB ...

  4. c#自定义控件窗体Click无法点击Lable的处理解决方案

    自定义控件做按钮,不继承Button,用Lable来做按钮文字时,点击空白处有效,但是点击lable不起作用的处理方案. 很简单,就是在Lable添加Click事件,事件中添加代码:OnClick(e ...

  5. (十七)c#Winform自定义控件-基类窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  6. (十九)c#Winform自定义控件-停靠窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  7. (二十)c#Winform自定义控件-有后退的窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  8. (二十二)c#Winform自定义控件-半透明窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  9. (二十三)c#Winform自定义控件-等待窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

随机推荐

  1. RDIFramework.NET V2.9版本 WinFom部分新增与修正的功能

    RDIFramework.NET  V2.9版本 WinFom部分新增与修正的功能 转眼间RDIFramework.NET框架走了快6个年头了,随着一个版本一个版本的升级改造,现在已经越来越完美了.使 ...

  2. OleContainer控件介绍

    OLEContainer 控件的主要属性 1)  AllowInPlace              property AllowInPlace:Boolean;        这个属性用于决定启动O ...

  3. Linux中的软硬链接

    说到Linux中的软硬链接,就必须谈一下Linux的文件系统的组成的重要部分iNode和block. 首先是iNode,先用一张图了解一下iNode在Linux文件系统中的地位: Linux中的文件的 ...

  4. Quartz.NET

    http://www.360doc.com/userhome.aspx?userid=11741424&cid=2#

  5. c# 中get和post的方法

    用GET发送数据则用REQUEST.QUERYSTRING[''ID'']接收 一.request.aspx 二.request.aspx.cs 三运行效果: 以下是数据发送的途径http://loc ...

  6. C++ 学习笔记(3) —— 內联函数

    内联函数的用处: 用空间换取时间,在调用时不用每次都写调用的汇编. 什么时候内联: 比较小的函数:只有两三行 在循环里循环调用的函数 什么时候不内联: 比较大的函数,2.30行的 递归的函数

  7. swift中editingStyleForRowAtIndexPath的写法

    效果图: 首先要实现这句tableView.setEditing(true, animated: true)才能弹出左侧的小圆圈 然而在oc中tableview删除的写法百度一下很常见但是swift中 ...

  8. 微信JS SDK PHP Demo

    一.JSSDK类定义 <?php class JSSDK { private $appId; private $appSecret; public function __construct($a ...

  9. JAVA基础知识之JDBC——RowSet

    RowSet概念 在C#中,提供了一个DataSet,可以把数据库的数据放在内存中进行离线操作(读写),操作完成之后再同步到数据库中去,Java中则提供了类似的功能RowSet. RowSet接口继承 ...

  10. python学习之for语句

    1.range数字范围 for i in range(5): print (i) 结果显示: 0 1 2 3 4 2.列表显示 ']: print ("current num:", ...