csharp:FlowLayoutPanel
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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | /// <summary> /// 集合添加的控件 /// 涂聚文20150339 /// </summary> public void AddNewTextBox() { Point p = new Point(); Label lb1 = new Label(); this .Controls.Add(lb1); lb1.Text = "关系名称" ; lb1.Top = cLeft * 25; lb1.RightToLeft = RightToLeft.Yes; cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(lb1); System.Windows.Forms.ComboBox cmb = new ComboBox(); relationshipTypeViewTitile.SetCombox(cmb); this .Controls.Add(cmb); cmb.Top = cLeft * 25; cmb.Size = new System.Drawing.Size(121, 20); cmb.Left = 2; flowLayoutPanel1.Controls.Add(cmb); Label lb2 = new Label(); this .Controls.Add(lb2); lb2.Text = "关系人姓名" ; lb2.Top = cLeft * 25; lb2.RightToLeft = RightToLeft.Yes; cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(lb2); System.Windows.Forms.TextBox txtName = new System.Windows.Forms.TextBox(); this .Controls.Add(txtName); txtName.Name = "txtName" ; txtName.Top = cLeft * 25; txtName.Left = 200; txtName.Text = "" ; // "TextBox" + this.cLeft.ToString(); cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(txtName); Label lbtel = new Label(); this .Controls.Add(lbtel); lbtel.Text = "关系人电话" ; lbtel.Top = cLeft * 25; lbtel.RightToLeft = RightToLeft.Yes; lbtel.Left = 200; cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(lbtel); System.Windows.Forms.TextBox txtTel = new System.Windows.Forms.TextBox(); this .Controls.Add(txtTel); txtTel.Name = "txtTel" ; txtTel.Top = cLeft * 25; txtTel.Left = 200; txtTel.Text = "" ; // "TextBox" + this.cLeft.ToString(); cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(txtTel); Label lb4 = new Label(); this .Controls.Add(lb4); lb4.Text = "关系人生出日期" ; lb4.RightToLeft = RightToLeft.Yes; lb4.Top = cLeft * 25; cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(lb4); System.Windows.Forms.DateTimePicker dtime = new System.Windows.Forms.DateTimePicker(); dtime.Size = new Size(155, 30); this .Controls.Add(dtime); cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(dtime); Label lb5 = new Label(); this .Controls.Add(lb5); lb5.Text = "关系人描述" ; lb5.Top = cLeft * 25; lb5.RightToLeft = RightToLeft.Yes; cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(lb5); System.Windows.Forms.TextBox txtRelationDesc = new System.Windows.Forms.TextBox(); this .Controls.Add(txtRelationDesc); txtRelationDesc.Name = "txtRelationDesc" ; txtRelationDesc.Top = cLeft * 25; txtRelationDesc.Left = 200; txtRelationDesc.Text = "" ; // "TextBox" + this.cLeft.ToString(); cLeft = cLeft + 1; flowLayoutPanel1.Controls.Add(txtRelationDesc); } /// <summary> /// 添加控件事件 /// 涂聚文20150339 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click( object sender, EventArgs e) { AddNewTextBox(); } /// <summary> /// 获取添的控件的值 /// 涂聚文20150339 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click( object sender, EventArgs e) { int s = 0; int k = 0; int n = 0; for ( int i = 0; i < flowLayoutPanel1.Controls.Count; i++) { if (flowLayoutPanel1.Controls[i].GetType() == typeof (ComboBox)) //按类型查找 { customerRelationTypeID = ((ComboBox) this .flowLayoutPanel1.Controls[i]).SelectedValue.ToString(); } if (flowLayoutPanel1.Controls[i].GetType() == typeof (TextBox)) { //MessageBox.Show(((TextBox)this.flowLayoutPanel1.Controls[i]).Name); if (((TextBox) this .flowLayoutPanel1.Controls[i]).Name.Contains( "txtName" )) { customerRelationName = ((TextBox) this .flowLayoutPanel1.Controls[i]).Text.Trim(); } if (((TextBox) this .flowLayoutPanel1.Controls[i]).Name.Contains( "txtTel" )) { customerRelationTel = ((TextBox) this .flowLayoutPanel1.Controls[i]).Text.Trim(); } if (((TextBox) this .flowLayoutPanel1.Controls[i]).Name.Contains( "txtRelationDesc" )) { customerRelationDesc = ((TextBox) this .flowLayoutPanel1.Controls[i]).Text.Trim(); } } if (flowLayoutPanel1.Controls[i].GetType() == typeof (DateTimePicker)) //按类型查找 { customerBirthday = ((DateTimePicker) this .flowLayoutPanel1.Controls[i]).Value; } if (IsOdd5(i)) { customerRelationContactsId = CustomerRelationContactsId; if (Operator == 1) { customerRelationshipListInfo.CustomerBirthday = customerBirthday; customerRelationshipListInfo.CustomerRelationContactsId = customerRelationContactsId; customerRelationshipListInfo.CustomerRelationDesc = customerRelationDesc; customerRelationshipListInfo.CustomerRelationName = customerRelationName; customerRelationshipListInfo.CustomerRelationTel = customerRelationTel; customerRelationshipListInfo.CustomerRelationTypeID = customerRelationTypeID; k = customerRelationshipListBLL.InsertCustomerRelationshipList(customerRelationshipListInfo); //MessageBox.Show(customerRelationTypeID + customerRelationName + customerRelationTel); n++; } } } if (n > 0) { DialogResult dresult = MessageBox.Show( "添加了" + n.ToString() + "条联系人" , "提示" , MessageBoxButtons.OK, MessageBoxIcon.Information); if (dresult == DialogResult.OK) { this .Close(); this .DialogResult = DialogResult.OK; } } else { DialogResult dresult = MessageBox.Show( "存在问题,添加了" + n.ToString() + "条联系人" , "提示" , MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (dresult == DialogResult.No) { this .Close(); this .DialogResult = DialogResult.OK; } if (dresult == DialogResult.Yes) { return ; } } } /// <summary> /// 判断奇偶数的函數 /// </summary> /// <param name="n"></param> /// <returns></returns> public static bool IsOdd2( int n) { return Convert.ToBoolean(n % 2); } /// <summary> /// /// </summary> /// <param name="n"></param> /// <returns></returns> public static bool IsOdd5( int n) { int b = 0; bool isb = false ; b = n % 9; if (n > 0) { if (b == 0) { isb = true ; } } return isb; } |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
分类:
CSharp code
标签:
csharp
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2013-03-29 Csharp:The .dat File using BinaryReader and BinaryWriter Convert to DataTable
2013-03-29 Javascript:IE打印页面设置,预览,首页设置