首页  编辑  

批量处理控件属性

Tags: /C#/界面处理/   Date Created:

for ( int i = 1 ; i <= 100 ; i ++ )

{

    Control [] vControls = Controls . Find( string . Format( "checkBox{0}" , i), true );

    if (vControls . Length > 0 && vControls[ 0 ] is CheckBox )

       (( CheckBox )vControls[ 0 ]) . Checked = true ;

}

/////----------------

foreach ( Control vControl in Controls)

{

    if (vControl is CheckBox )

       (( CheckBox )vControl) . Checked = true ;

}