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

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

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

  1. C#窗体自定义控件

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...

  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. 百度SDK的使用第一天

    //获取自定义的经纬度上添加位置气泡,大头钉 BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init]; CLLocation ...

  2. GridView合并表头、多重表头(转)

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) ...

  3. Solr5.0配置中文分词包

    Solr中默认的中文分词是用Lucene的一元分词包. 现在说明在Solr5.0中配置Lucene的SmartCN中文分词包. 1,进入Solr的安装目录,我这里是:/root/nutch/solr- ...

  4. console ouput 与 重定向输出 效率对比

    昨天做一个程序的性能测试的时候,由于用了自动化脚本,测试的时候直接把结果(包括执行时间等信息)输出到文件.后来我在调整源代码的时候单独跑了可执行文件,此时结果是输出到控制台(printf).大约100 ...

  5. tab左右箭头切换(修改后)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. HTML静态网页 图片热点、框架、表单

    图片热点: 规划出图片上的一个区域,可以做出超链接,直接点击图片区域就可以完成跳转的效果. 示例: 网页划区: 在一个网页里,规划出一个区域用来展示另一个网页的内容. 示例: 框架: 1.frames ...

  7. css渐变颜色在线制作

    http://www.colorzilla.com/gradient-editor/

  8. 非静态的字段、方法或属性“System.Web.UI.Page.ClientScript...”要求对象引用 (封装注册脚本)

    在写项目时想对asp.net的注册前台脚本事件进行封装,就添加了一个BasePage.cs页面,但一直报错‘非静态的字段.方法或属性“System.Web.UI.Page.ClientScript.. ...

  9. cookie案例-显示用户上次访问网站的时间

    package cn.itcast.cookie; import java.io.IOException; import java.io.PrintWriter; import java.util.D ...

  10. sax解析原理与案例

    package itcast.sax; import java.io.IOException; import javax.xml.parsers.ParserConfigurationExceptio ...