zoukankan      html  css  js  c++  java
  • winform textbox文本框设置多行输入小技巧总结

    对于我们经常要对文本框进行多行输入后进行查询、插入、删除、更新操作等,要很方便的从其他诸如Excel中进行复制粘贴的数据来说,textbox文本框必须设置

    为多行属性: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('
    ');//将文本框的内容按回车进行分组
                    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("
    ", "") + "',";//将分隔开的字符串进行重新组装中间加,逗号
                    }
                    if (strBarcodeList.Length > 0)
                        //strBarcodeList = strBarcodeList.Replace("
    ","");//撤除将字符串最后的回车符
                        strBarcodeList = strBarcodeList.Remove(strBarcodeList.Length - 1);//去除字符串最后的逗号
    以上方便将字符串转换为:"A,B,C"这样子的格式。



  • 相关阅读:
    9
    8
    7
    6
    5
    第四周
    作业14-数据库
    作业13-网络
    作业12-流与文件
    作业11-多线程
  • 原文地址:https://www.cnblogs.com/zorrobubble/p/3596912.html
Copyright © 2011-2022 走看看