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);
}
}
}
}

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. ios - 自动布局框架编写(更多功能完善中)

    之前用的storyboard以及xib挺多的,最近看到朋友用第三方框架---自动布局约束框架在添加控件约束的时候老实报错.后来自己就试了试纯代码创建以及约束控件.但是纯代码约束一个控件还可以,如果约束 ...

  2. cell长按出错

    错误的原因: *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reaso ...

  3. spring1冲刺感想与总结

    感想与体会: 通过团队合作的第一个sprint,我们知道如何在团队合作中做好自己,还有与队友不合时,如何和平处理问题.产品负责人是一个重要的的角色,他负责任务的安排,处理合作中意见不统一的问题.通过这 ...

  4. busybox-1.12.2编译提示“混合的隐含和普通规则”错误解决

    编译环境:CentOs 7.1 Ubuntu 12.0.4 都可以 交叉编译工具:gcc -4.3.2 (博创6410平台) 问题描述:执行make menuconfig命令的时候,提示Makefil ...

  5. Spring 文章推荐

    spring mvc 异常统一处理方式:http://www.cnblogs.com/xd502djj/archive/2012/09/24/2700490.html 在springmvc中使用hib ...

  6. OBD K线抓包 III

    14230 HL激活, 5BPS又称 00  //电平激活 C1 33 F1 81 66  //14230的Enter命令 83 F1 11 C1 EF 8F C4 //回应了,一个命令就回应了... ...

  7. 如何清理photoshop cs6 被升级的烦人的adobe creative cloud组件

    安装photoshop cs6(虽然目前已经退出到cc 2015,不过因激活成熟度等,我还是偏向于使用cs6,够用!),默认安装adobe application manager. 不过如果不小心单独 ...

  8. java中快速排序的理解以及实例

    所谓的快速排序的思想就是,首先把数组的第一个数拿出来做为一个key,在前后分别设置一个i,j做为标识,然后拿这个key对这个数组从后面往前遍历,及j--,直到找到第一个小于这个key的那个数,然后交换 ...

  9. HTML5正则表单式验证电子邮件

    <input type="text" title="email" required pattern="[^@]+@[^@]+\.[a-zA-Z] ...

  10. Android动画View Animation

    Animations 一.Animations介绍 Animations是一个实现android UI界面动画效果的API,Animations提供了一系列的动画效果,可以进行旋转.缩放.淡入淡出等, ...