none
代码输入字符文本中字符过多 RRS feed

全部回复

  • Hi,

    什么是字符文本的字符过多?你能详细解释一下吗?

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2019年10月8日 5:12
    版主
  • 检查字符的长度,超过限制就提醒用户,或者自动截断;或者在输入界面限制最大输入字符数量;


    family as water

    2019年10月14日 8:45

  • 这里有一个Winforms项目的简单示例你可以参考一下。

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            // 判断长度是否超过限制(5)
            if (textBox1.Text.Length > 5)
            {
                // 弹窗提示
                MessageBox.Show("Exceed the upper limit");
                // 字符截断限制长度
                textBox1.Text = textBox1.Text.Substring(0, 5);
                // 重置光标位置
                textBox1.Select(5, 0);
                textBox1.ScrollToCaret();
            }
        }

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2019年10月14日 9:08
    版主