回复 1楼DCAgile的帖子
通过 TextField name 属性来对应,通过 Text 来获取,测试代码如下:
- private void Form1_Load(object sender, EventArgs e)
- {
- this.textControl1.Text = "你好";
- TextField tf1 = new TextField();
- tf1.Name = "Name";
- tf1.Text = "晓明";
- this.textControl1.Select(tf1.Start,tf1.Length);
- this.textControl1.Selection.Underline= FontUnderlineStyle.Single;
- this.textControl1.TextFields.Add(tf1);
- }
- private void 获取TextFieldToolStripMenuItem_Click(object sender, EventArgs e)
- {
- foreach (TextField t in this.textControl1.TextFields)
- {
- if (t.Name=="Name")
- {
- string name = t.Text;
- }
- }
- }
复制代码 |