C#窗体 自定义控件
- 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
- 54
- 55
- 56 }
- 57 }
- 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#窗体 自定义控件的更多相关文章
- C#窗体自定义控件
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...
- 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 ...
随机推荐
- 百度SDK的使用第一天
//获取自定义的经纬度上添加位置气泡,大头钉 BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init]; CLLocation ...
- GridView合并表头、多重表头(转)
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) ...
- Solr5.0配置中文分词包
Solr中默认的中文分词是用Lucene的一元分词包. 现在说明在Solr5.0中配置Lucene的SmartCN中文分词包. 1,进入Solr的安装目录,我这里是:/root/nutch/solr- ...
- console ouput 与 重定向输出 效率对比
昨天做一个程序的性能测试的时候,由于用了自动化脚本,测试的时候直接把结果(包括执行时间等信息)输出到文件.后来我在调整源代码的时候单独跑了可执行文件,此时结果是输出到控制台(printf).大约100 ...
- tab左右箭头切换(修改后)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- HTML静态网页 图片热点、框架、表单
图片热点: 规划出图片上的一个区域,可以做出超链接,直接点击图片区域就可以完成跳转的效果. 示例: 网页划区: 在一个网页里,规划出一个区域用来展示另一个网页的内容. 示例: 框架: 1.frames ...
- css渐变颜色在线制作
http://www.colorzilla.com/gradient-editor/
- 非静态的字段、方法或属性“System.Web.UI.Page.ClientScript...”要求对象引用 (封装注册脚本)
在写项目时想对asp.net的注册前台脚本事件进行封装,就添加了一个BasePage.cs页面,但一直报错‘非静态的字段.方法或属性“System.Web.UI.Page.ClientScript.. ...
- cookie案例-显示用户上次访问网站的时间
package cn.itcast.cookie; import java.io.IOException; import java.io.PrintWriter; import java.util.D ...
- sax解析原理与案例
package itcast.sax; import java.io.IOException; import javax.xml.parsers.ParserConfigurationExceptio ...