(更新时间)2021年5月21日 仓库温控系统(Winform) 18 封装Panel中显示Form页方法
【摘要】
public static class FormUtility
{
//静态类中的静态方法---扩展方法
//检查一个Form是否已打开
public static bool C...
public static class FormUtility
{
//静态类中的静态方法---扩展方法
//检查一个Form是否已打开
public static bool CheckOpenForm(string frmName)
{
bool bl = false;
foreach (Form f in Application.OpenForms)
{
if (f.Name == frmName)
{
bl = true;
break;
}
}
return bl;
}
//获取指定Name的Form
public static Form GetOpenForm(string frmName)
{
Form frm = null;
foreach (Form f in Application.OpenForms)
{
if (f.Name == frmName)
{
frm = f;
break;
}
}
return frm;
}
/// <summary>
/// 将指定 的Form显示到Panel之中
/// </summary>
/// <param name="panel"></param>
/// <param name="frm"></param>
public static void AddPanelForm(this Panel panel, Form frm)
{
bool bExist = false;
//检查:Form是否已打开
if (CheckOpenForm(frm.Name))
{
Form f = GetOpenForm(frm.Name);
//判断,当前显示的Form是否已经显示在Panel
bool bl = false;
foreach (Control c in panel.Controls)
{
if (c is Form)
{
Form form = c as Form;
if (form.Name == f.Name)
{
frm = form;
bl = true;
bExist = true;
break;
}
}
}
if (!bl)
{
frm = f;
}
}
panel.Controls.Clear();
frm.TopLevel = false;
frm.FormBorderStyle = FormBorderStyle.None;
frm.WindowState = FormWindowState.Maximized;
frm.Dock = DockStyle.Fill;
panel.AutoScroll = true;
panel.Controls.Add(frm);
frm.Show();
}
/// <summary>
/// DataGridView 基本操作列的显示处理
/// </summary>
/// <param name="dgv"></param>
/// <param name="isDel"></param>
public static void ShowDgvCols(this DataGridView dgv, bool isDel)
{
dgv.Columns["colEdit"].Visible = !isDel;
dgv.Columns["colDel"].Visible = !isDel;
dgv.Columns["colRecover"].Visible = isDel;
dgv.Columns["colRemove"].Visible = isDel;
}
/// <summary>
/// 获取操作类型名(删除/恢复/移除)
/// </summary>
/// <param name="delCode"></param>
/// <returns></returns>
public static string GetDelName(int delCode)
{
string delName = "删除";
switch (delCode)
{
case 1:delName = "删除";break;
case 0: delName = "恢复"; break;
case 2: delName = "移除"; break;
}
return delName;
}
/// <summary>
/// 加载仓库下拉框
/// </summary>
/// <param name="cbo"></param>
public static void LoadCboStores(ComboBox cbo)
{
StoreBLL storeBLL = new StoreBLL();
List<StoreInfo> storeList = storeBLL.GetAllStores();
storeList.Insert(0, new StoreInfo()
{
StoreId = 0,
StoreName = "-----请选择-----"
});
cbo.DisplayMember = "StoreName";
cbo.ValueMember = "StoreId";
cbo.DataSource = storeList;
cbo.SelectedIndex = 0;
}
/// <summary>
/// 分区状态列表
/// </summary>
/// <returns></returns>
public static List<RegionStateModel> RegionStateList()
{
return new List<RegionStateModel>()
{
new RegionStateModel(){RegionState =-1,StateText="全部"},
new RegionStateModel(){RegionState =0,StateText="低温"},
new RegionStateModel(){RegionState =1,StateText="正常"},
new RegionStateModel(){RegionState =2,StateText="高温"}
};
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
文章来源: codeboy.blog.csdn.net,作者:愚公搬代码,版权归原作者所有,如需转载,请联系作者。
原文链接:codeboy.blog.csdn.net/article/details/117107053
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)