winform textbox文本框设置多行输入小技巧总结
2013-06-24 10:02
344 查看
对于我们经常要对文本框进行多行输入后进行查询、插入、删除、更新操作等,要很方便的从其他诸如Excel中进行复制粘贴的数据来说,textbox文本框必须设置
为多行属性:Multiline 属性设置为True,其次对字符串进行一下处理:
以上方便将字符串转换为:"A,B,C"这样子的格式。
为多行属性:Multiline 属性设置为True,其次对字符串进行一下处理:
string Ocno=this.txt_OCNO.Text.Trim(); string strValue = this.txt_Barcode.Text;//设置文本框的内容 string shopNoValue = this.CB_ShopNo.Text; if (Ocno == "" && strValue == "" && CB_ShopNo.Text == "") { MessageBox.Show("批次、条码、车间不能同时为空,至少要输入一个", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string[] arrValue = strValue.Split('\r');//将文本框的内容按回车进行分组 string strBarcodeList = "";//设置一个字符串接受分割开的每一个字符 DateTime DT_Start = Convert.ToDateTime(this.DTP_Start.Text); DateTime DT_end = Convert.ToDateTime(this.DTP_End.Text); for (int i = 0; i < arrValue.Length; i++) { strBarcodeList = strBarcodeList + "'" + arrValue[i].Replace("\n", "") + "',";//将分隔开的字符串进行重新组装中间加,逗号 } if (strBarcodeList.Length > 0) //strBarcodeList = strBarcodeList.Replace("\r","");//撤除将字符串最后的回车符 strBarcodeList = strBarcodeList.Remove(strBarcodeList.Length - 1);//去除字符串最后的逗号
以上方便将字符串转换为:"A,B,C"这样子的格式。
相关文章推荐
- winform textbox文本框设置多行输入小技巧总结
- 使用Custom Validator控件设置Textbox文本框输入长度
- C#Winform限制TextBox文本框只能输入文本的格式
- C#之WinForm基础 textbox控件变高,由单行输入改为多行输入
- [原]创建三个输入文本框,当光标离开文本框的时候如果文本框为空,则将文本框背景色设置为红色,如果不为空则为白色。提示:焦点进入控件的事件是onfocus,焦点离开控件的事件是onblur
- WinForm实现为TextBox设置水印文字功能
- 在JAVA中为文本框设置输入限制
- 文本框限制输入类型的相关代码设置
- Winform窗体下,AcceptButton已经设置了Button,TextBox仍能接收回车键
- 设置多行 TextBox 滚动条位置
- c# winform 让textbox中只能输入int64位的数字
- js控制文本框只能输入数字(小技巧)
- winform textbox.text设置换行技巧备忘
- winform的textbox中只能输入数字和一个小数点
- eclipse 小技巧,设置输入任何字母都有快捷提示.
- WINFORM 加载时设置输入焦点
- 设置文本框只能输入数字
- 创建三个输入文本框,当光标离开文本框的时候如果文本框为空,则将文本框背景色设置为红色,如果不为空则为白色。提示:焦点进入控件的事件是onfocus,焦点离开控件的事件是onblur
- Winform 输入提示 水印 TextBox ComboBox
- C# 设置文本框等控件只能输入 正负整数或小数