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经典样式.. 不说多丑也绝称不上好看..有时为了用户体验就不得不需要想办法弄漂亮一点..皮肤包会是一个不错的选择.. 不废话了..开整.. 首先从网上下载免 ...
随机推荐
- flume 读取tcp写到hdfs
# Please paste flume.conf here. Example: # Sources, channels, and sinks are defined per # agent name ...
- mysql日志与备份恢复
一.mysql日志: mysql的日志种类有很多,常见的有二进制日志,一般查询日志,满查询日志,中继日志,事务日志等,具体信息可以通过 mysql> SHOW GLOBAL VARIABLES ...
- Happy New Year
今年的元旦能明显感觉到节日的狂欢.一方面,论文的事情,压抑了好久,另一方面,把自己融入节日之中.所以才有了节日的深度参与. 早上还是按时的起床,看了朋友圈,内心却能专注于平静.因为见到了优秀的人,才发 ...
- C#小程序飞行棋关卡操作
飞行棋关卡操作 1.分析设计 飞行棋的基本规则为二人轮流掷骰子,则此处为循环结构,然后根据投掷出的点数进行前进<注:在每一步前进之后均应该判断是否走完了游戏>,在遇到关卡时进行相应的操作, ...
- linux mysql远程连接
今天在本地连接linux服务端的mysql始终报错61,谷歌后找到原因: linux的mysql默认是不允许远程连接操作的,在stack上面找到方法:修改mysql配置文件/usr/local/mys ...
- js面向对象的实现(example 一)
//通过函数原型链(prototype)的方式来构造对象 //通过闭包的方式来对元素类进行封装 //通过函数原型链的方式来构造对象的方法和类的继承 //通过以上步骤就可以用函数的形式来实现类的,封装, ...
- zendstudio快捷键复制行Ctrl+Alt+向下无效的解决方法
今天不断地在百度输入类似"zendstudio快捷键复制行Ctrl+Alt+向下无效"这样的关键字,里面搜索到的内容都是在说系统的显卡驱动Ctrl+Alt+方向键和ZendStud ...
- wampserver配置域名
装载自http://blog.csdn.net/znb26/article/details/51204313
- Druid Monitor监控JavaSE,杀cmd端口进程
1.需要在启动命令添加相关jvm参数 -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname -Dcom.sun.management.jm ...
- ubuntu 14.4 中文语言包安装问题
1.安装前,请选择更新源,在系统设定 system setting 里,选择software and updates 里,选择中国的源,用于快速更新语言包 2.在language support里选择 ...