UI 界面 控件遍历访问

 foreach (Control ctl in this.groupBox1.Controls)
            
{
                
if (ctl is ComboBox)
                
{
                    ((ComboBox)ctl).SelectedIndexChanged 
+= new EventHandler(ComBoxSelectedIndexChanged);
                }

                
if (ctl is CheckBox)
                
{
                    ((CheckBox)ctl).CheckedChanged 
+= new EventHandler(CheckChanged);
                }

            }


public void ComBoxSelectedIndexChanged(object sender, EventArgs e)
{
    ComboBox cmb 
= ((ComboBox)sender);
    
//
}



  
//组合凭证查询
        public Control FindControlName(string StrName)
        
{
            
foreach (Control ctl in this.groupBox1.Controls)
            
{
                
if (ctl.Name != null && ctl.Name.ToString() == StrName)
                
{
                    
return ctl;
                }

            }

            
return null;
        }


    
/// <summary>
        
/// Get Control 
        
/// </summary>
        
/// <param name="Tag">Control Tag</param>
        
/// <returns>Control</returns>

        public Control FindControl(string Tag)
        
{
            
foreach (Control ctl in this.groupBox1.Controls)
            
{
                
if (ctl.Tag != null && ctl.Tag.ToString() == Tag)
                
{
                    
return ctl;
                }

            }

            
return null;
        }


 
//收费标志
            CheckBox cbox = null;
            
//授权标志
            CheckBox cbox1 = null;
            
帐户类型
posted @ 2007-01-30 14:40  jhtchina  阅读(725)  评论(1)    收藏  举报