本文整理汇总了C#中System.Windows.Forms.Control.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# Control.OfType方法的具体用法?C# Control.OfType怎么用?C# Control.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Control
的用法示例。
在下文中一共展示了Control.OfType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InnerDisable
private void InnerDisable(Control.ControlCollection controls)
{
foreach (TextBox text in controls.OfType<TextBox>().ToList())
{
text.BackColor = SystemColors.Window;
text.BorderStyle = BorderStyle.None;
text.Location = new Point(text.Location.X, text.Location.Y + 5);
text.ReadOnly = true;
}
foreach (RadioButton radio in controls.OfType<RadioButton>().ToList())
if (!radio.Checked)
radio.Enabled = false;
foreach (ComboBox combo in controls.OfType<ComboBox>().ToList())
combo.Enabled = false;
}
示例2: controlisinedit
public bool controlisinedit( Control controls)
{
foreach (Control c in controls.OfType<TextBox>())
{
if (c.Text != "")
return true;
}
//else
return false;
}
示例3: FindControl
private static object FindControl(string name, Control.ControlCollection c)
{
Control control = c.Find(name, true).FirstOrDefault();
if (control != null)
return control;
foreach (MenuStrip menu in c.OfType<MenuStrip>())
{
var item = menu.Items.Find(name, true).FirstOrDefault();
if (item != null)
return item;
}
foreach (ContextMenuStrip strip in FindContextMenuStrips(c.OfType<Control>()))
{
var item = strip.Items.Find(name, true).FirstOrDefault();
if (item != null)
return item;
}
return null;
}
示例4: ClearBindingsRecursively
private static void ClearBindingsRecursively(Control.ControlCollection collection)
{
if (collection == null)
return;
foreach (var item in collection.OfType<Control>())
{
ClearBindingsRecursively(item.Controls);
item.ClearBindings(true, true);
}
}
示例5: ClearBindings
/// <summary>
/// コントロールバインドクリア
/// </summary>
/// <param name="controls">Formに配置したコントロール</param>
protected void ClearBindings(Control.ControlCollection controls)
{
controls.OfType<Control>()
.ToList()
.ForEach(x => x.DataBindings.Clear());
}
示例6: SetReadonlyControls
private void SetReadonlyControls(Control.ControlCollection controlCollection)
{
if (controlCollection == null)
{
return;
}
foreach (TextBoxBase c in controlCollection.OfType<TextBoxBase>())
{
c.ReadOnly = true;
}
}