效果图:

代码:

 //分页或者多次加载时,需要删除之前产生的lable等控件
   for (int tabID = ; tabID < ; tabID++)
{
foreach (Control control in this.tableLayoutPanel2.Controls)
{ // 遍历所有TextBox...
if (control is PictureBox)
{
PictureBox t = (PictureBox)control;
if (control.TabIndex == tabID)
{
if (tabID > list.Count - )
{
for (int i = tabID; i < ; i++)
{
//this.tableLayoutPanel2.Controls.Remove(control);
t.ImageLocation = null;
t.Controls.Remove(t.Controls[tabID.ToString()]);
string d = ("NO" + tabID.ToString());
t.Controls.Remove(t.Controls[d]);
t.Tag = -;
}
break;
} t.ImageLocation = list[tabID].VehicleImage;
t.Tag = (list[tabID].Id).ToString();
string m = ("NO" + tabID.ToString());
t.Controls.Remove(t.Controls[tabID.ToString()]);
t.Controls.Remove(t.Controls[m]);
Label C = new Label();
C.Parent = t;
C.Width = ;
C.Text = list[tabID].VehicleNumber;
C.Font = new Font("", );
C.ForeColor = Color.Black; C.Dock = DockStyle.Top;
C.BackColor = Color.Transparent;
C.TextAlign = ContentAlignment.TopLeft;
C.AutoSize = false;
C.Name = "NO" + tabID.ToString(); Label B = new Label();
B.Parent = t;
B.Width = ;
B.Text = list[tabID].VehicleZT;
B.Font = new Font("", );
switch (list[tabID].VehicleZT) {
case "待派":
B.ForeColor = Color.Blue;
break;
case "已派":
B.ForeColor = Color.Green;
break;
case "维修":
B.ForeColor = Color.Yellow ;
break;
case "停驶":
B.ForeColor = Color.Red;
break;
}
B.Dock = DockStyle.Bottom;
B.BackColor = Color.Transparent;
B.TextAlign = ContentAlignment.BottomRight;
B.AutoSize = false;
B.Name = tabID.ToString();
}
}
}
}

winform PictureBox图片上动态添加Label或其他控件的更多相关文章

  1. (转载)VC/MFC 工具栏上动态添加组合框等控件的方法

    引言 工具条作为大多数标准的Windows应用程序的 一个重要组成部分,使其成为促进人机界面友好的一个重要工具.通过工具条极大方便了用户对程序的操作,但是在由Microsoft Visual C++开 ...

  2. VC/MFC 工具栏上动态添加组合框等控件的方法

    引言 工具条作为大多数标准的Windows应用程序的一个重要组成部分,使其成为促进人机界面友好的一个重要工具.通过工具条极大方便了用户对程序的操作,但是在由Microsoft Visual C++开发 ...

  3. Android 在程序中动态添加 View 布局或控件

    有时我们需要在程序中动态添加布局或控件等,下面用程序来展示一下相应的方法: 1.addView 添加View到布局容器 2.removeView 在布局容器中删掉已有的View 3.LayoutPar ...

  4. asp.net 动态添加多个用户控件

    动态添加多个相同用户控件,并使每个用户控件获取不同的内容. 用户控件代码: 代码WebControls using System; using System.Collections.Generic;  ...

  5. C#实现在图片上动态写内容

    之前在项目上遇到这么一个需求,就是要在图片上写内容,而且要求是动态,我所谓的动态就是在图片上写的内容是动态的.网上找了找,很多人实现了网图片上写内容的功能,但是,并没有实现动态.所以在这里把我的解决办 ...

  6. winform窗体传值和动态添加控件

    1.跳转窗体时传值 //将要显示的页面实例化 RoleMenuForm rmf = new RoleMenuForm(); try { //在此给RoleMenuForm 窗体中的变量roleId传值 ...

  7. vue组件上动态添加和删除属性

    1.vue组件上动态添加和删除属性 // 添加 this.$set(this.obj, 'propName', val) // 删除 this.$delete(this.obj, 'propName' ...

  8. m_Orchestrate learning system---二十六、动态给封装好的控件添加属性

    m_Orchestrate learning system---二十六.动态给封装好的控件添加属性 一.总结 一句话总结:比如我现在封装好了ueditor控件,我外部调用这个控件,因为要写数据到数据库 ...

  9. ASP.NET#在设计窗口上添加了一个SqlDataSource控件后,没有显示出来?

    在设计窗口上添加了一个SqlDataSource控件后,没有显示出来,但后台代码是有的 处理的办法:菜单栏->视图->可视辅助->ASP.NET非可视控件 (我用的是VS2012)

随机推荐

  1. ubuntu系统调整时区和时间

    date: 2019-05-30  10:14:23 author:headsen  chen 个人原创博客,转录需要注明作者和出处. 1,安装ntpdate,同步标准时间 root@hk-confl ...

  2. SpringBoot之封装json对象返回json数据

    /** * @description:封装json对象,所有返回结果都使用它 **/ public class Result<T> { private int code;// 业务自定义状 ...

  3. com.alibaba.fastjson.JSONObject;的使用

    转: com.alibaba.fastjson.JSONObject;的使用 2018-11-04 23:51:23 mameng1998 阅读数 6404更多 分类专栏: java   1  POM ...

  4. QDateTime QString

    QDateTime格式化  yyyy-MM-dd hh:mm:ss QString getFormatDateStr(QDateTime dateTimeParam) { qDebug() <& ...

  5. 《最长的一帧》 osg3.4 osgViewer::View::init() osgViewer::Viewer::getContexts()

    开始:osgViewer/ViewerBase.cpp   389行,startThreading()函数,启动线程   void ViewerBase::startThreading() { if ...

  6. Oracle ORA-00984: column not allowed here

    ORA-00984错误: 列在此处不允许当数据以char的形式存在时,应加单引号,则插入数据库就不会出现类似错误.

  7. Java解压tar.Z文件(使用Apache Commons-compress)

    这里使用apache commons compress对.tar.Z格式文件进行解压. 对于一个文件test.tar.Z,我们可以将解压过程理解为: 将test.tar.Z解压为test.tar: 将 ...

  8. Hibrtnate组件映射

    Component映射 在hibernate中Component映射采用<component>标签即可 Component是某个实体的逻辑组成部分,它与实体类的主要差别在于,它没有oidC ...

  9. GraphQL学习之原理篇

    前言 在上一篇文章基础篇中,我们介绍了GraphQL的语法以及类型系统,算是对GraphQL有个基本的认识.在这一篇中,我们将会介绍GraphQL的实现原理.说到原理,我们就不得不依托于GraphQL ...

  10. .Net Core 请求上下文IHttpContextAccessor

    namespace Microsoft.AspNetCore.Http { public interface IHttpContextAccessor { HttpContext HttpContex ...