回复 7楼etsoft的帖子
试试这段代码看能否符合你的需求:
- private void Form1_Load(object sender, EventArgs e)
- {
- this.textControl1.TextFieldClicked += new TextFieldEventHandler(textControl1_TextFieldClicked);
- }
- void textControl1_TextFieldClicked(object sender, TextFieldEventArgs e)
- {
- this.textControl1.Select(e.TextField.Start, 1);
- string selectText = this.textControl1.Selection.Text;
- this.textControl1.Selection.Text = " " + selectText;
- this.textControl1.Select(e.TextField.Start, 1);
- this.textControl1.Selection.Text = "";
- }
- private void addTextFieldToolStripMenuItem_Click(object sender, EventArgs e)
- {
- TextField tf1 = new TextField();
- tf1.Text = "C";
- tf1.Deleteable = false;
- tf1.Editable = false;
- TextField tf2 = new TextField();
- tf2.Text = "D";
- tf2.Deleteable = false;
- tf2.Editable = false;
- this.textControl1.TextFields.Add(tf1);
- this.textControl1.TextFields.Add(tf2);
- }
复制代码 |