602544

博客园 首页 新随笔 联系 订阅 管理

环境:Net2.0
调用时直接Utility.ChangeChildEditMode(this.Form, false);

public static void ChangeChildEditMode(Control con, bool blnEditMode)
    
{
        
int i = 0;
        
foreach (Control c in con.Controls)
        
{

            
if (c is TextBox)
            
{
                ((TextBox)c).Enabled 
= blnEditMode;
            }

            
else if (c is Button)
            
{
                ((Button)c).Enabled 
= blnEditMode;
            }

            
else if (c is DropDownList)
            
{
                ((DropDownList)c).Enabled 
= blnEditMode;
            }

            
else if (c is ListBox)
            
{
                ((ListBox)c).Enabled 
= blnEditMode;
            }

            
else if (c is CheckBox)
            
{
                ((CheckBox)c).Enabled 
= blnEditMode;
            }

            
else if (c is CheckBoxList)
            
{
                ((CheckBoxList)c).Enabled 
= blnEditMode;
            }

            
else if (c is RadioButton)
            
{
                ((RadioButton)c).Enabled 
= blnEditMode;
            }

            
else if (c is RadioButtonList)
            
{
                ((RadioButtonList)c).Enabled 
= blnEditMode;
            }

            
else if (c is HyperLink)
            
{
                ((HyperLink)c).Enabled 
= blnEditMode;
            }

            
else if (c.HasControls())
            
{
                ChangeChildEditMode(c, blnEditMode);
                i
++;
            }

        }

    }
posted on 2006-12-09 22:23  狼牙  阅读(164)  评论(0编辑  收藏  举报