C#窗体自定义控件

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#窗体自定义控件的更多相关文章
- C#窗体 自定义控件
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Dr ...
- WPF自定义控件与样式(13)-自定义窗体Window & 自适应内容大小消息框MessageBox
一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: 自定义 ...
- 【转】WPF自定义控件与样式(13)-自定义窗体Window & 自适应内容大小消息框MessageBox
一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等. 本文主要内容: 自定义Window窗体样式: 基于自定义窗体实现自定义MessageB ...
- c#自定义控件窗体Click无法点击Lable的处理解决方案
自定义控件做按钮,不继承Button,用Lable来做按钮文字时,点击空白处有效,但是点击lable不起作用的处理方案. 很简单,就是在Lable添加Click事件,事件中添加代码:OnClick(e ...
- (十七)c#Winform自定义控件-基类窗体
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
- (十九)c#Winform自定义控件-停靠窗体
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
- (二十)c#Winform自定义控件-有后退的窗体
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
- (二十二)c#Winform自定义控件-半透明窗体
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
- (二十三)c#Winform自定义控件-等待窗体
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
随机推荐
- cocos2dx 3.x(实现帧动画(人物动画,跑马灯效果)的几种方法)
//创建一个跑酷的精灵 auto sprite = Sprite::create("1.png"); //设置精灵的坐标 sprite->setPosition(Ve ...
- HttpClient(JAVA)使用笔记
HTTPCLIENT 此工具是由apache基金会支持开发的一套 开源 http client 组件, 目前属于 http components的一部分, 官网:http://hc.apache.or ...
- Apache Commons 工具集
一.Commons BeanUtils http://jakarta.apache.org/commons/beanutils/index.html 说明:针对Bean的一个工具集.由于Bean往往是 ...
- AngularJS安装配置与基础概要整理(上)
以前整理的,可供参考. 安装: 1.首先要安装node.js和它的npm包管理系统.(nodejs相关待整理) 2.安装grunt .grunt是一个基于任务的Javascript工程命令行构建工具. ...
- HAL驱动库学习-SPI
如何使用SPI库1 声明SPI hanlde, 例如: SPI_HandleTypeDef hspi2 通过实现HAL_SPI_MspInit()函数初始化底层资源 以下两个必须进行初始化 a 使能s ...
- 安装第三方库出现 Python version 2.7 required, which was not found in the registry
安装第三方库出现 Python version 2.7 required, which was not found in the registry 建立一个文件 register.py 内容如下. 然 ...
- maven+springMVC+mybatis+mysql详细过程
1.工程目录 a.在src/main/java文件夹中,新建包cn.springmvc.model(存放javabean), cn.springmvc.dao(存放spring与mybatis连接接口 ...
- POJ - 1107 W's Cipher
POJ - 1107 W's Cipher Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u De ...
- Live writer
使用起来还是蛮方便的,安装速度很快,配置也不麻烦.
- WORD基础快捷键
选择 Alt+Shift+上下 移动整行 Ctrl+上 移动到行首 Ctrl+Shift+上下 选择到行首尾 shift+del 删除整段 ...