1 private Object GetCurrentCtrlTopForm(Control ctrObject)
2 {
3 if (ctrObject == null)
4 return null;
5
6 #region 控件所在窗体
7 System.Windows.Forms.Control pctrl = ctrObject.Parent;
8 while (true)
9 {
10 if (pctrl is System.Windows.Forms.Form)
11 break;
12 else
13 {
14 pctrl = pctrl.Parent;
15 if (pctrl is System.Windows.Forms.Form)
16 {
17 break;
18 }
19 }
20 }
21 return pctrl;
22 #endregion
23 //窗体
24 //containerForm = (System.Windows.Forms.Form)pctrl;
25 //if (!containerForm.Controls.Contains(this.textpanel))
26 // containerForm.Controls.Add(textpanel);
27 }
28
29 private String GetClassInfo()
30 {
31 string str = "";
32 //取得当前方法命名空间
33 str += "命名空间名:" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Namespace + "\n";
34 //取得当前方法类全名
35 str += "类名:" + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "\n";
36 //取得当前方法名
37 str += "方法名:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\n";
38 str += "\n";
39
40 System.Diagnostics.StackTrace ss = new System.Diagnostics.StackTrace(true);
41 System.Reflection.MethodBase mb = ss.GetFrame(1).GetMethod();
42 //取得父方法命名空间
43 str += mb.DeclaringType.Namespace + "\n";
44 //取得父方法类名
45 str += mb.DeclaringType.Name + "\n";
46 //取得父方法类全名
47 str += mb.DeclaringType.FullName + "\n";
48 //取得父方法名
49 str += mb.Name + "\n";
50 return str;
51 }