批量设置窗体控件上的属性
2008-01-19 10:24
211 查看
/// <summary>
/// 清空控件上的TextBox文本中的值,ComboBox、Button设置为灰色,
/// </summary>
/// <param name="IsEnabled">是否显示所有控件</param>
/// <param name="status">状态信息</param>
/// <param name="ctr">控件集合</param>
public void ClearControlsTextValue(ref bool IsEnabled,DeviceStatusInfo status,Control.ControlCollection ctr)
{
if (status.PowerState == 1 || status.NetState == 1)// || status.ErrorState == "1")
{
foreach (Control ctrl in ctr)
{
if (ctrl is TextBox)
{
ctrl.Text = "";
}//End if;判断是不是文本控件。
if (ctrl is ComboBox)
{
ComboBox comboBoxPower = ctrl as ComboBox;
if (comboBoxPower.Tag == null)
{
comboBoxPower.Enabled = false;
}//End if;判断是不是电源下拉框控件
}//End if;判断是不是下拉框控件。
if (ctrl is ProgressBar)
{
(ctr as ProgressBar).Enabled = false;
}//End if;判断是不是进度条控件。
if (ctrl.HasChildren)
{
ClearControlsTextValue(ref IsEnabled, status,ctrl.Controls);
}//End if; 递归子控件
}//End foreach;遍历所有控件。
IsEnabled = true;
}//End if;判断设备的电源、网络、整机、故障状态。
}
/// 清空控件上的TextBox文本中的值,ComboBox、Button设置为灰色,
/// </summary>
/// <param name="IsEnabled">是否显示所有控件</param>
/// <param name="status">状态信息</param>
/// <param name="ctr">控件集合</param>
public void ClearControlsTextValue(ref bool IsEnabled,DeviceStatusInfo status,Control.ControlCollection ctr)
{
if (status.PowerState == 1 || status.NetState == 1)// || status.ErrorState == "1")
{
foreach (Control ctrl in ctr)
{
if (ctrl is TextBox)
{
ctrl.Text = "";
}//End if;判断是不是文本控件。
if (ctrl is ComboBox)
{
ComboBox comboBoxPower = ctrl as ComboBox;
if (comboBoxPower.Tag == null)
{
comboBoxPower.Enabled = false;
}//End if;判断是不是电源下拉框控件
}//End if;判断是不是下拉框控件。
if (ctrl is ProgressBar)
{
(ctr as ProgressBar).Enabled = false;
}//End if;判断是不是进度条控件。
if (ctrl.HasChildren)
{
ClearControlsTextValue(ref IsEnabled, status,ctrl.Controls);
}//End if; 递归子控件
}//End foreach;遍历所有控件。
IsEnabled = true;
}//End if;判断设备的电源、网络、整机、故障状态。
}
相关文章推荐
- 批量设置窗体控件上的属性
- 设置Form窗体中的控件的属性
- 使用匿名函数在后台线程中设置窗体控件属性
- 使用匿名函数在后台线程中设置窗体控件属性 ()转
- c#创建窗体,向窗体添加控件,设置控件大小位置等属性,写控件的响应
- 关联事件,向窗体中添加控件,设置控件属性等系列操作
- 以线程安全的方式设置WinForm窗体控件的属性
- 窗体主控件Dock属性设置为fill后,被工具条压住了,怎么办?
- 在一个窗体中设置另一个窗体的控件属性
- 窗体主控件Dock属性设置为Fill后,被工具条盖住了
- winform窗体中 ComboBox 控件的DropDownWidth属性根据显示的文本设置下拉列表的显示宽度
- FORM窗体 控件设置DOCK属性问题
- winform 跨线程设置或读取控件的属性
- 背水一战 Windows 10 (67) - 控件(控件基类): DependencyObject - CoreDispatcher, 依赖属性的设置与获取, 依赖属性的变化回调
- 获取或设置datalist内的控件的属性和值
- winform窗体属性设置
- 设置UI控件的Layer属性(边框可见,边框颜色,边框宽度,边框圆角)
- 模拟了个FoxMail的账号属性设置 TZListBox 控件
- DataGridView 控件中轻松设置DataGridViewComboBoxColumn数据绑定属性。
- DEV控件:gridControl常用属性设置