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经典样式.. 不说多丑也绝称不上好看..有时为了用户体验就不得不需要想办法弄漂亮一点..皮肤包会是一个不错的选择.. 不废话了..开整.. 首先从网上下载免 ...
随机推荐
- android ImageView 中的ScaleType
center :居中,不执行缩放 centerCrop:按原始比例缩放,裁剪中间部分 centerInside:按原始比例缩放,居中,不裁剪 fitCenter:居中缩放 fitStart:上对齐缩放 ...
- assert断言基础用法
Python的assert是用来检查一个条件,如果它为真,就不做任何事.如果它为假,则会抛出AssertError并且包含错误信息
- Git self-learning
---恢复内容开始--- 使用后的总结 git config --global user.name "" #设置和查看用户名git config --global user.ema ...
- Notepad++的xml文本格式化
1.需要使用插件 2.使用插件
- AX7: HOW TO USE CLASS EXTENSION METHODS
AX7: HOW TO USE CLASS EXTENSION METHODS To create new methods on a standard AX class without custo ...
- js实现图片无缝连接
效果图 1.首先先看看html和css代码 <style> *{padding:0;margin:0;} #div1{margin:100px auto;background:red;wi ...
- MySQL 基础语句
MySQL 基础语句 多个知识点 ----------------------------------------------------------------------------------- ...
- python Django教程 之 模型(数据库)、自定义Field、数据表更改、QuerySet API
python Django教程 之 模型(数据库).自定义Field.数据表更改.QuerySet API 一.Django 模型(数据库) Django 模型是与数据库相关的,与数据库相关的代码 ...
- vi/vim 的使用
vi/vim 的使用 基本上 vi/vim 共分为三种模式,分别是一般模式.编辑模式与指令列命令模式. 这三种模式的作用分别是: 一般模式:以 vi 打开一个档案就直接进入一般模式了(这是默认的模式) ...
- Spark Streaming源码解读之Driver容错安全性
本期内容 : ReceivedBlockTracker容错安全性 DStreamGraph和JobGenerator容错安全性 Driver的安全性主要从Spark Streaming自己运行机制的角 ...