第一版:

private void RefreshControl(PanelEx panel, bool enabled, bool isClear)
{
for (int i = ; i < panel.Controls.Count; i++)
{
if (panel.Controls[i] is PanelEx)
{
PanelEx panel1 = panel.Controls[i] as PanelEx;
RefreshControl(panel1, enabled, isClear);
}
else if (panel.Controls[i] is DevComponents.DotNetBar.TabControl)
{
DevComponents.DotNetBar.TabControl tabControl = panel.Controls[i] as DevComponents.DotNetBar.TabControl;
RefreshControl(tabControl, enabled, isClear);
}
else if (panel.Controls[i] is TextBoxX)
{
TextBox textbox = panel.Controls[i] as TextBoxX;
textbox.Enabled = enabled;
if (isClear)
textbox.Clear();
}
else if (panel.Controls[i] is DateTimeInput)
{
DateTimeInput dtInput = panel.Controls[i] as DateTimeInput;
dtInput.Enabled = enabled;
if (isClear)
dtInput.Value = DateTime.Parse("2999/1/1");
}
else if (panel.Controls[i] is ButtonX)
{
ButtonX btn = panel.Controls[i] as ButtonX;
btn.Enabled = enabled;
}
else if (panel.Controls[i] is CheckBoxX)
{
CheckBoxX checkBoxX = panel.Controls[i] as CheckBoxX;
checkBoxX.Enabled = enabled;
if (isClear)
checkBoxX.Checked = false;
}
else if (panel.Controls[i] is BarcodeControl)
{
BarcodeControl barcodeControl = panel.Controls[i] as BarcodeControl;
barcodeControl.Enabled = enabled;
if (isClear)
barcodeControl.Data = "";
}
else if (panel.Controls[i] is ComboBoxEx)
{
ComboBoxEx comboBoxEx = panel.Controls[i] as ComboBoxEx;
comboBoxEx.Enabled = enabled;
if (isClear)
comboBoxEx.Text = "";
}
}
} private void RefreshControl(DevComponents.DotNetBar.TabControl tabControl, bool enabled, bool isClear)
{
int index = tabControl.SelectedTabIndex;
for (int i = ; i < ; i++)
{
TabControlPanel panel = tabControl.SelectedPanel;
foreach (Control item in panel.Controls)
{
if (item is TextBoxX)
{
TextBox textbox = item as TextBoxX;
textbox.Enabled = enabled;
if (isClear)
textbox.Clear();
}
else if (item is CheckBoxX)
{
CheckBoxX checkBoxX = item as CheckBoxX;
checkBoxX.Enabled = enabled;
if (isClear)
checkBoxX.Checked = false;
}
else if (item is ButtonX)
{
ButtonX btn = item as ButtonX;
btn.Enabled = enabled;
}
else if (item is DataGridViewX)
{
DataGridViewX grid = item as DataGridViewX;
if (isClear)
{
if (grid.DataSource != null && grid.Rows.Count != )
{
DataTable dt = (DataTable)grid.DataSource;
dt.Rows.Clear();
grid.DataSource = dt;
//grid.Rows.Clear();
}
}
}
else if (item is DateTimeInput)
{
DateTimeInput dtInput = item as DateTimeInput;
dtInput.Enabled = enabled;
if (isClear)
{
dtInput.Value = DateTime.Parse("2999/1/1");
}
}
else if (item is PictureBox)
{
PictureBox pic = item as PictureBox;
pic.Enabled = enabled;
if (isClear)
{
pic.Image = null;
}
}
else if (item is PanelEx)
{
PanelEx panel1 = item as PanelEx;
RefreshControl(panel1, enabled, isClear);
}
}
if (!tabControl.SelectNextTab())
{
tabControl.SelectedTabIndex = ;
if (tabControl.SelectedTabIndex == index)
break;
}
}
tabControl.SelectedTabIndex = index;
}

第二版

private void RefreshControl(Control baseControl,bool enabled, bool isClear)
{
foreach (Control Control in baseControl.Controls)
{
if (Control is PanelEx)
{
PanelEx panel = Control as PanelEx;
RefreshControl(panel, enabled, isClear);
}
else if (Control is DevComponents.DotNetBar.TabControl)
{
DevComponents.DotNetBar.TabControl tabControl = Control as DevComponents.DotNetBar.TabControl;
RefreshControl(tabControl, enabled, isClear);
}
else if (Control is TabControlPanel)
{
TabControlPanel tabPanel = Control as TabControlPanel;
RefreshControl(tabPanel, enabled, isClear);
}
else if (Control is TextBoxX)
{
TextBox textbox = Control as TextBoxX;
textbox.Enabled = enabled;
if (isClear)
textbox.Clear();
}
else if (Control is ButtonX)
{
ButtonX btn = Control as ButtonX;
btn.Enabled = enabled;
}
else if (Control is DateTimeInput)
{
DateTimeInput dtInput = Control as DateTimeInput;
dtInput.Enabled = enabled;
if (isClear)
dtInput.Value = DateTime.Parse("2999/1/1");
}
else if (Control is CheckBoxX)
{
CheckBoxX checkBoxX = Control as CheckBoxX;
checkBoxX.Enabled = enabled;
if (isClear)
checkBoxX.Checked = false;
}
else if (Control is BarcodeControl)
{
BarcodeControl barcodeControl = Control as BarcodeControl;
barcodeControl.Enabled = enabled;
if (isClear)
barcodeControl.Data = "";
}
else if (Control is ComboBoxEx)
{
ComboBoxEx comboBoxEx = Control as ComboBoxEx;
comboBoxEx.Enabled = enabled;
if (isClear)
comboBoxEx.Text = "";
}
else if (Control is DataGridViewX)
{
DataGridViewX grid = Control as DataGridViewX;
if (isClear)
{
if (grid.DataSource != null && grid.Rows.Count != )
{
DataTable dt = (DataTable)grid.DataSource;
dt.Rows.Clear();
grid.DataSource = dt;
//grid.Rows.Clear();
}
}
}
else if (Control is PictureBox)
{
PictureBox pic = Control as PictureBox;
pic.Enabled = enabled;
if (isClear)
{
pic.Image = null;
}
}
else if (Control is GroupPanel)
{
RefreshControl(Control, enabled, isClear);
}
}
}

winform空间批量控制的更多相关文章

  1. Winfrom 简单的进度条小程序

    使用Winform空间编写简单的进度条小程序: 所需控件:Lable 标签  TextBox  文本框  progressBar  进度条控件  timer 定时器 下面是源码及效果图: /// &l ...

  2. winform Form窗体和UserControl用户空间嵌入Panel容器并填充

    private void sbtbflList_Click(object sender, EventArgs e) { ucxmflList ucfl = new ucxmflList();//用户控 ...

  3. 【基于WinForm+Access局域网共享数据库的项目总结】之篇三:Access远程连接数据库和窗体打包部署

    篇一:WinForm开发总体概述与技术实现 篇二:WinForm开发扇形图统计和Excel数据导出 篇三:Access远程连接数据库和窗体打包部署 [小记]:最近基于WinForm+Access数据库 ...

  4. C# 报表设计器 (winform 设计端)开发与实现生成网页的HTML报表

    记得2010年之前,公司的项目基本上都要用到报表,以前我们常用的方法就是针对客户的需求来定制化开发(基本上是死写代码)来实现,经常导致项目经常性的延期,因为客户的需求经常会变化,随着用户的使用认知度的 ...

  5. [WPF]建立自适应窗口大小布局的WinForm窗口

    编写WinForm程序时,都会碰到一个问题.就是WinForm窗口在不同分辨率下的大小问题.举例说明,你编写的WinForm窗口在1024×768下是合适.匀称的.不过,如果用户的计算机的分辨率为14 ...

  6. C#实现WinForm DataGridView控件支持叠加数据绑定

    我们都知道WinForm DataGridView控件支持数据绑定,使用方法很简单,只需将DataSource属性指定到相应的数据源即可,但需注意数据源必须支持IListSource类型,这里说的是支 ...

  7. WinForm GDI+ 资料收集

    UI(User Interface)编程在整个项目开发过程中是个颇为重要的环节,任何好的解决方案若没有良好的用户界面呈现给最终用户,那么就算包含了最先进的技术也不能算是好程序.UI编程体现在两个方面, ...

  8. Winform添加Label

    Info from : http://www.csharpwin.com/csharpspace/6253r7952.shtml 本例子主要是介绍如何在 C#开发WinForm中加入一个组件,如果你想 ...

  9. WinForm使用皮肤图文步骤

    Winfrom本身样式提供的是Windows经典样式.. 不说多丑也绝称不上好看..有时为了用户体验就不得不需要想办法弄漂亮一点..皮肤包会是一个不错的选择.. 不废话了..开整.. 首先从网上下载免 ...

随机推荐

  1. linux中mysql如何设置为开机启动

    开机启动命令 chkconfig mysqld on 查询是否设置为开机启动命令 chkconfig --list mysqld 结果为 mysqld 0:关闭 1:关闭 2:启动 3:启动 4:启动 ...

  2. flex acionscript png图片去除多余空白,生成合适大小图片

    //最小矩形(非透明最小区域) public static function getMinRect(target:BitmapData):Rectangle{   return target.getC ...

  3. 解决sublime text3 文件名,小框框的办法

    解决sublime text3 文件名,小框框的办法 之前一直都是用的英文命名的文件夹,到前几天才发现,用中文,来命名文件夹出现了乱码问题. 今天晚上,自己也在网上去百度了很多方案,好像大部分都不太有 ...

  4. jquery 城市三级联动

    js代码 /*城市三级联动 * @method cityChange * @param allProvince,allCity,allDistrict */ function cityChange(p ...

  5. log4j输出日志到不同文件

    1.先看log4j的配置文件 log4j.properties 没有此文件就在根目录下创建一个: log4j.rootLogger=INFO,R,Client log4j.appender.R=org ...

  6. python的optparse模块使用

    name or flags:就是参数的名称或标志 -f --file,-q --quit 等,其中-f表示option的缩写,--file表示option的全称 nargs:命令行参数的个数,一般使用 ...

  7. SQL Server提高事务复制效率优化(一)总体概述

      随着公司业务的发展,数据量增长迅速,在解决Scale Out的同时,还要考虑到主从的复制延迟问题,尽量降到1s以内满足线上业务,如果不调整,SQL Server默认的配置可能平均要3s左右.生产的 ...

  8. MySQL 第九天(核心优化三)

    一.昨天内容回顾 索引设计依据 与数据表有关系的sql语句都统计出来 where order by or等等条件的字段适当做索引 原则: 频率高的sql语句 执行时间长的sql语句 业务逻辑重要的sq ...

  9. python中string模块

    >>> import string >>> string.ascii_letters 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL ...

  10. 面试iOS遇到这种笔试《操作评估》

    一.开发团队需求: 开发一款软件需要前端后台和推广的人.1,首先要明确设计这个APP的理念2,合理的列出APP的需求3,找到后台人员让他们搭好后台数据4,前端的人负责展示到界面上5,推广人员负责让更多 ...