#region 文本框指定位置加入回车符
private void button1_Click(object sender, EventArgs e)
{
#region
// 查询首字母位置
//string str = "ab0ab0ab0ab0";
//int one = str.IndexOf("0"); //返回0出现的位置【索引】 //for (int i=0;i<str.Length;i++)
//{
// one = str.IndexOf("0", ++one); //第二次出现的位置
// if (one==-1)
// {
// break;//未找到
// }
// MessageBox.Show(one.ToString());
//}
#endregion string str = textBox1.Text.Trim();
int one = str.IndexOf("</option>"); //返回0出现的位置【索引】
str = str.Insert(one + , "\r\n");
for (int i = ; i < str.Length; i++)
{
one = str.IndexOf("</option>", ++one); //第二次出现的位置
if (one == -)
{
break;//未找到
}
else
{
str = str.Insert(one + , "\r\n");
}
}
textBox1.Text = str;
}
#endregion
#region list转string 去除text指定行
List<string> list = new List<string>();
private void button2_Click(object sender, EventArgs e)
{
list.Clear();
//
foreach (string line in textBox1.Lines)
{
if (!line.Contains("select"))
{
list.Add(line);
}
}
textBox1.Text= string.Join("\r\n", list.ToArray());
}
#endregion

//----------分隔符号

// 功能 遍历html select 标签 中的键值对  加入到集合

using System;
using System.Collections.Generic;
using System.Windows.Forms; namespace HTML_下拉框_添加字典
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<string> list = new List<string>();
private void button1_Click(object sender, EventArgs e)
{
//加入换行符
string str = textBox1.Text.Trim();
int one = str.IndexOf("</option>"); //返回0出现的位置【索引】
str = str.Insert(one + , "\r\n");
for (int i = ; i < str.Length; i++)
{
one = str.IndexOf("</option>", ++one); //第二次出现的位置
if (one == -)
{
break;//未找到
}
else
{
str = str.Insert(one + , "\r\n");
}
}
textBox1.Text = str;
} private void button2_Click(object sender, EventArgs e)
{
//去除select
list.Clear();
//
foreach (string line in textBox1.Lines)
{
if (!line.Contains("select"))
{
list.Add(line);
}
}
textBox1.Text = string.Join("\r\n", list.ToArray()); } private void button3_Click(object sender, EventArgs e)
{
//输出数据
string str;
list.Clear();
//输出主要数据
foreach (string line in textBox1.Lines) //遍历文本框
{
str = line.Replace("<option value=\"", "").Replace("\">", "#").Replace("</option>", ""); //替换数据
list.Add(str.Insert(str.IndexOf("#") + , txtTJ.Text.Trim())); //插入指定数据
} textBox1.Text = string.Join("\r\n", list.ToArray()); //集合转字符串 以回车符 分割 } }
}

//循环查找字符串并截取

  List<string> elements = new List<string>();
int docIntT = ;
int zz = ;
docIntT = str.IndexOf(docStrT); //第一个标题位置
for (int i = ; i < str.Length; i++)
{
docIntT = str.IndexOf(docStrT, (docIntT+));
if (docIntT==-)
{
elements.Add(str.Substring(zz)); //从zz截取到最后
break; //未找到
}
elements.Add(str.Substring(zz, docIntT-zz));
zz = docIntT;
}

C# 遍历文本框的更多相关文章

  1. winfrom 遍历文本框

    //winform中Control是所有组件的基类 ; i <= ; i++) { Control[] coltxtSpeed = this.Controls.Find("txtbox ...

  2. js/jquery获取文本框的值与改变文本框的值

    我们就用它来学习获取文本框的值及改变文本框的值. 代码如下 复制代码 <script>function get1(){ document.getElementById("txtb ...

  3. Java 读取Word文本框中的文本/图片/表格

    Word可插入文本框,文本框中可嵌入文本.图片.表格等内容.对文档中的已有文本框,也可以读取其中的内容.本文以Java程序代码来展示如何读取文本框,包括读取文本框中的文本.图片以及表格等. [程序环境 ...

  4. C# 读取Word文本框中的文本、图片和表格(附VB.NET代码)

    [概述] Word中可插入文本框,在文本框中可添加文本.图片.表格等内容.本篇文章通过C#程序代码介绍如何来读取文本框中的文本.图片和表格等内容.附VB.NET代码,有需要可作参考. [程序环境] 程 ...

  5. 遍历input文本框

    最近写的一个项目中,页面中有很多的“text文本框”和“select下拉框” 校验input框和select框是否非空,如果为空给出提示.反之,隐藏提示内容. html  页面中的input类型有ty ...

  6. [原创]C#应用WindowsApi实现查找(FindWindowEx)文本框(TextBox、TextEdit)。

    /// <summary> /// 获取文本框控件 /// </summary> /// <param name="hwnd">文本框所在父窗口 ...

  7. JS来推断文本框内容改变事件

       oninput,onpropertychange,onchange的使用方法 onchange触发事件必须满足两个条件: a)当前对象属性改变,而且是由键盘或鼠标事件激发的(脚本触发无效) b) ...

  8. IE下支持文本框和密码框placeholder效果的JQuery插件

    基于jQuery实现的,主要用于IE下实现placeholder效果,可同时支持文本和密码输入框.placeholder是HTML5新增的一个属性,当input设置了该属性后,该值的内容将作为灰色提示 ...

  9. 机房收费系统总结之4——VB.NET 轻松解决判断文本框、组合框为空问题

    纵观机房收费系统,判断文本框.组合框为空问题无非两种情况.第一种:判断窗体中所有文本框.组合框是否为空.第二种:判断一部分文本框.组合框是否为空.下面看看是如何实现这两种情况的. 第一种:判断窗体中所 ...

随机推荐

  1. [bzoj3207]花神的嘲讽计划Ⅰ[可持久化线段树,hash]

    将每k个数字求一个哈希值,存入可持久化线段树,直接查询即可 #include <iostream> #include <algorithm> #include <cstd ...

  2. P1331 海战 洛谷

    题目描述 在峰会期间,武装部队得处于高度戒备.警察将监视每一条大街,军队将保卫建筑物,领空将布满了F-2003飞机.此外,巡洋船只和舰队将被派去保护海岸线.不幸的是因为种种原因,国防海军部仅有很少的几 ...

  3. Source Insight 与 Source Navigator ,Understand ,Crystal FLOW 源代码阅读工具

    http://www.sourceinsight.com/update.html http://www.oschina.net/p/sourcenavigator/ http://www.cnblog ...

  4. 找出二叉查找树中指定结点的”下一个&quot;结点(也即中序后继)

    设计一个算法.找出二叉查找树中指定结点的"下一个"结点(也即中序后继).能够假定每一个结点都含有指向父结点的连接. watermark/2/text/aHR0cDovL2Jsb2c ...

  5. IntelliJ IDEA中出现could not auto wired错误提示处理方式

    IntelliJ IDEA中出现could not auto wired错误提示处理方式 程序可以正常运行,就是出现错误提示: 学习了:http://blog.csdn.net/xlxxybz1314 ...

  6. ListView点击或选中item改变背景

    点击或选中ListView中的一项后.使item背景改变,失去焦点相同显示选中的背景.又一次选中另外一项才刷新: 在Adapter中配置: public class MyAdapter extends ...

  7. Ant报错之out of memory

    用Ant打包一个比較大的项目的时候,遇到OutOfMemory的问题,求助于Google和百度,网上的解决方式非常多,可是个人认为不够具体全面.我的问题须要综合两种方法才解决.把方案记下来.以期帮助大 ...

  8. IOS7中动态计算UILable的高度

    .h文件 #import <UIKit/UIKit.h> @interface UILabel (ContentSize) - (CGSize)contentSize; @end .m文件 ...

  9. ASP.NET MVC 客户端验证失败后表单仍然提交问题

    客户端验证失败后表单仍然提交问题!导致页面刷新,辛辛苦苦输入的内容荡然无存. 多么奇怪的问题.按道理,验证失败,就应该显示各种错误信息,不会提交表单才对.而现在,错误信息正常显示,但页面却刷新了一遍. ...

  10. Linux I2C驱动分析(三)----i2c_dev驱动和应用层分析 【转】

    本文转载自:http://blog.chinaunix.net/uid-21558711-id-3959287.html 分类: LINUX 原文地址:Linux I2C驱动分析(三)----i2c_ ...