博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
查找所有页面中的按钮
阅读量:4936 次
发布时间:2019-06-11

本文共 3270 字,大约阅读时间需要 10 分钟。

protected void InitButtons()        {            string strSql = "";            strSql = @"select MFormName  from MenuInfo where SeqNo=@SeqNo";            DbCommand cmd12 = myGlobal.db.GetSqlStringCommand(strSql);            myGlobal.db.AddInParameter(cmd12, "@SeqNo", DbType.Int32, 1);            menuInfo = new List
(); try { using (IDataReader reader = myGlobal.db.ExecuteReader(cmd12)) { while (reader.Read()) { menuInfo.Add(new MenuInfo() { MFormName = reader["MFormName"].ToString() }); } } } catch { } if (menuInfo != null && menuInfo.Count > 0) { IList
buttList = new List
(); foreach (MenuInfo m in menuInfo) { BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic; Assembly asm = Assembly.Load("mytext"); Form frm = (Form)asm.CreateInstance(m.MFormName); //frmMeA frm = new frmMeA(); FieldInfo[] fields = frm.GetType().GetFields(flag); foreach (var fi in fields) { if (fi.FieldType == typeof(Button) || fi.FieldType == typeof(SimpleButton)) { Control c = fi.GetValue(frm) as Control; ButtonInfo bModel = new ButtonInfo(); bModel.ButtonType = 1; bModel.ButtonTitle = c.Name; bModel.ButtonPop = c.Text; buttList.Add(bModel); } if (fi.FieldType == typeof(BarButtonItem)) { BarButtonItem c = fi.GetValue(frm) as BarButtonItem; if (c != null) { ButtonInfo bModel = new ButtonInfo(); bModel.ButtonType = 1; bModel.ButtonTitle = c.Name; bModel.ButtonPop = c.Caption; buttList.Add(bModel); } } if (fi.FieldType == typeof(ToolStripMenuItem)) { ToolStripMenuItem c = fi.GetValue(frm) as ToolStripMenuItem; if (c != null) { ButtonInfo bModel = new ButtonInfo(); bModel.ButtonType = 1; bModel.ButtonTitle = c.Name; bModel.ButtonPop = c.Text; buttList.Add(bModel); } } } } var buttList1 = buttList; } }

  

转载于:https://www.cnblogs.com/qufly/p/3445183.html

你可能感兴趣的文章