我想找出groupBox下所有控件该怎么做啊
控件的名字和ID
高手帮帮我吧

解决方案 »

  1.   

                foreach (Control ctl in this.groupBox1)
                {
                    Console.WriteLine(ctl.Name);
                    Console.WriteLine(ctl.Handle.ToString());
                }
      

  2.   

    foreach(Control c in this.groupbox1.Controls)
    {
     if (c.GetType().ToString() == "") 
    {}
    }
      

  3.   


                foreach (Control ctl in this.groupBox1.Controls)
                {
                    Console.WriteLine(ctl.Name);
                    Console.WriteLine(ctl.Handle.ToString());
                }
      

  4.   

    自己进程的winform窗体使用ls的方法.
    非自己进程的window使用FindWindowEx或EnumWindowEx枚举子窗体句柄,
    然后使用GetWindowLong+GWL_ID获取窗体ID,至于名字...对于系统原生的窗体,
    只有窗体类名,没有名字一说.
      

  5.   

    可是像checkBox这样的控件,没有办法获取他是否选中
      

  6.   

    这个checkbox 是你的进程里的还是别的进程里的?
    是不是.net winform的?对于原生窗体,如果
    是一个对话框的话,可以使用IsDlgButtonChecked
    获取,否则只能自己发BM_GETSTATE消息
      

  7.   

    checkbox是动态生成的,每次打开form可能都会不一样,比如个数会多会少,但是每一个的checkbox的name是不一样的
      

  8.   

                foreach (Control ctl in this.groupBox1.Controls)
                {
                    CheckBox cb = ctl as CheckBox;
                    if (cb != null)
                    {
                        Console.WriteLine(cb.Name +" Checked :"+cb.CheckState.ToString());
                    }
                    Console.WriteLine(ctl.Name);
                    Console.WriteLine(ctl.Handle.ToString());
                }