winform空间批量控制
第一版:
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空间批量控制的更多相关文章
- Winfrom 简单的进度条小程序
使用Winform空间编写简单的进度条小程序: 所需控件:Lable 标签 TextBox 文本框 progressBar 进度条控件 timer 定时器 下面是源码及效果图: /// &l ...
- winform Form窗体和UserControl用户空间嵌入Panel容器并填充
private void sbtbflList_Click(object sender, EventArgs e) { ucxmflList ucfl = new ucxmflList();//用户控 ...
- 【基于WinForm+Access局域网共享数据库的项目总结】之篇三:Access远程连接数据库和窗体打包部署
篇一:WinForm开发总体概述与技术实现 篇二:WinForm开发扇形图统计和Excel数据导出 篇三:Access远程连接数据库和窗体打包部署 [小记]:最近基于WinForm+Access数据库 ...
- C# 报表设计器 (winform 设计端)开发与实现生成网页的HTML报表
记得2010年之前,公司的项目基本上都要用到报表,以前我们常用的方法就是针对客户的需求来定制化开发(基本上是死写代码)来实现,经常导致项目经常性的延期,因为客户的需求经常会变化,随着用户的使用认知度的 ...
- [WPF]建立自适应窗口大小布局的WinForm窗口
编写WinForm程序时,都会碰到一个问题.就是WinForm窗口在不同分辨率下的大小问题.举例说明,你编写的WinForm窗口在1024×768下是合适.匀称的.不过,如果用户的计算机的分辨率为14 ...
- C#实现WinForm DataGridView控件支持叠加数据绑定
我们都知道WinForm DataGridView控件支持数据绑定,使用方法很简单,只需将DataSource属性指定到相应的数据源即可,但需注意数据源必须支持IListSource类型,这里说的是支 ...
- WinForm GDI+ 资料收集
UI(User Interface)编程在整个项目开发过程中是个颇为重要的环节,任何好的解决方案若没有良好的用户界面呈现给最终用户,那么就算包含了最先进的技术也不能算是好程序.UI编程体现在两个方面, ...
- Winform添加Label
Info from : http://www.csharpwin.com/csharpspace/6253r7952.shtml 本例子主要是介绍如何在 C#开发WinForm中加入一个组件,如果你想 ...
- WinForm使用皮肤图文步骤
Winfrom本身样式提供的是Windows经典样式.. 不说多丑也绝称不上好看..有时为了用户体验就不得不需要想办法弄漂亮一点..皮肤包会是一个不错的选择.. 不废话了..开整.. 首先从网上下载免 ...
随机推荐
- 在Linux上编写C#程序
自从C#开源之后,在Linux编写C#程序就成了可能.Mono-project就是开源版本的C#维护项目.在Linux平台上使用的C#开发工具为monodevelop.安装方式如下: 首先需要安装一些 ...
- Angualr2 - 使用 VS2015
使用 Vs 2015 快速上手 Angular2 许多程序员希望能够使用 VS2015 作为 IDE 来开发 Angular 2 应用,这里介绍如何设置 VS2015,使用快速上手文件来搭建 ASP. ...
- WinForm DataGridView分页功能
WinForm 里面的DataGridView不像WebForm里面的GridView那样有自带的分页功能,需要自己写代码来实现分页,效果如下图: 分页控件 .CS: 1 using System; ...
- android上下文菜单
XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln ...
- nvm
nvm install stable #安装最新稳定版 node,现在是 5.0.0 nvm install 4.2.2 #安装 4.2.2 版本 nvm install 0.12.7 #安装 0.1 ...
- Spark Streaming源码解读之No Receivers彻底思考
本期内容 : Direct Acess Kafka Spark Streaming接收数据现在支持的两种方式: 01. Receiver的方式来接收数据,及输入数据的控制 02. No Receive ...
- Media Queries详解
Media Queries直译过来就是“媒体查询”,在我们平时的Web页面中head部分常看到这样的一段代码: <link href="css/reset.css" rel ...
- "递归"实现"约瑟夫环","汉诺塔"
一:约瑟夫环问题是由古罗马的史学家约瑟夫提出的,问题描述为:编号为1,2,-.n的n个人按顺时针方向围坐在一张圆桌周围,每个人持有一个密码(正整数),一开始任选一个正整数作为报数上限值m,从第一个人开 ...
- 编程模式之观察者模式(Observer)
观察者模式由四个角色组成:抽象主题角色,抽象观察者角色,具体主题角色,抽象观察者角色,具体观察者角色. 抽象主题角色(Subject):把所有的观察者角色的引用保存在一个集合中,可以有任意数量的观察者 ...
- sass揭秘之@mixin,%,@function
因为文章内含有很多sass代码,如需自己动手查看编译结果,推荐使用sassmeister这款在线编译工具,方便你阅读学习. 在阅读本文章之前,请先确认你已经阅读了上篇文章sass揭秘之变量,不然会给你 ...