如何在c#.net窗体中设置所有标签+文本框控件的常用字体大小和颜色属性。 [英] how to set common font size and color properties of all label + textbox controls in c#.net windows form.

查看:146
本文介绍了如何在c#.net窗体中设置所有标签+文本框控件的常用字体大小和颜色属性。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在同一c#.net窗体中设置多个标签和文本框控件的常用字体大小和颜色属性。





plz为代码提供解决方案.........

how to set common font size and color properties of multiple label and textbox controls in same c#.net windows form.


plz provide the code with solution.........

推荐答案

试一试: -

try it:-
foreach (Control ctr in this.Controls)
        {
            ctr.Font = SystemFonts.IconTitleFont;
            // controls in groupboxes are not child of main form
            if (ctr.HasChildren)
            {
                foreach (Control childControl in ctr.Controls)
                {
                    childControl.Font = SystemFonts.IconTitleFont;
                }
            }
        }


下面的代码可以帮助你...

< br $>


Belowing code will help you...


private void ResetAllControlsBackColor(Control control)
{
   control.BackColor = SystemColors.Control;
   control.ForeColor = SystemColors.ControlText;
   if(control.HasChildren)
   {
      // Recursively call this method for each child control.
      foreach(Control childControl in control.Controls)
      {
         ResetAllControlsBackColor(childControl);
      }
   }
}


hi


在C#.net中基于Windows的应用程序..



我想在C#中设置常用属性,如颜色,字体大小,高度,宽度,所有标签,按钮和文本框控件的字体类型.net表格.......



我该怎么办......

请提供代码那个......



i已经试过那个代码了,但它没有用........



private void ResetAllControlsBackColor(控制控件)

{

control.BackColor = SystemColors.Control;

control.ForeColor = SystemColors.ControlText;

if(control.HasChildren)

{

//为每个子控件递归调用此方法。

foreach(控制childControl in control.Controls)

{

ResetAllControlsBackColor(childControl);

}

}

}
hi
In C#.net windows based application..

I want to set common properties like color, font size, height, width, font type of all the label, button and textbox controls in C#.net forms .......

How can i do it ......
Please provide me code for that ......

i have tried that code , but it's not working ........

private void ResetAllControlsBackColor(Control control)
{
control.BackColor = SystemColors.Control;
control.ForeColor = SystemColors.ControlText;
if(control.HasChildren)
{
// Recursively call this method for each child control.
foreach(Control childControl in control.Controls)
{
ResetAllControlsBackColor(childControl);
}
}
}


这篇关于如何在c#.net窗体中设置所有标签+文本框控件的常用字体大小和颜色属性。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆