C#检查动态创建的richtextbox中的输入

时间:2016-08-27 04:23:21

标签: c# richtextbox

这就是我所拥有的:

private void button1_Click(object sender, EventArgs e)
    {
        //Creating the RichTextBox
        RichTextBox rtb = new RichTextBox();
        rtb.Location = new Point(20, 20);
        rtb.Width = 400;
        rtb.Height = 300;
        rtb.BackColor = Color.White;
        rtb.Font = new Font("Mistral", 16, FontStyle.Regular);
        int size = rtb.TextLength;
        rtb.AcceptsTab = true;
        rtb.ScrollBars = RichTextBoxScrollBars.Both;
        rtb.ReadOnly = false;
        rtb.MaxLength = rtb.TextLength;
        rtb.ShortcutsEnabled = true;
        rtb.EnableAutoDragDrop = true;
        Controls.Add(rtb);
}

我想使用

来大写用户输入
string text = rtb.Text.ToUpper();
rtb.Text = text;
rtb.SelectionStart = rtb.Text.Length;

为了实现这一点,我需要不断地将用户输入到rtb.Text 我怎样才能做到这一点? 提前谢谢。

1 个答案:

答案 0 :(得分:0)

有点搞乱:

using (Stream stream = response.GetResponseStream())
{
   StreamReader reader = new StreamReader(stream, Encoding.UTF8);
   String responseString = reader.ReadToEnd();
}

...或

 private void createDynamicRTB()
    {
        rtb.Location = new Point(20, 20);
        rtb.Width = 400;
        rtb.Height = 300;
        rtb.BackColor = Color.White;
        rtb.Font = new Font("Mistral", 16, FontStyle.Regular);
        int size = rtb.TextLength;
        rtb.AcceptsTab = true;
        rtb.ScrollBars = RichTextBoxScrollBars.Both;
        rtb.ReadOnly = false;
        rtb.MaxLength = rtb.TextLength;
        rtb.ShortcutsEnabled = true;
        rtb.EnableAutoDragDrop = true;
        Controls.Add(rtb);
    }
    RichTextBox rtb = new RichTextBox();
    private void button1_Click(object sender, EventArgs e)
    {
        //Capitalize
        rtb.Text = rtb.Text.ToUpper();


    }