[英]How To add * in Textbox Starting value and print into label in C#
I have some text boxes
in my form where the user need to enter the different prices of article, what I want to do is to automatically add Starting value *
whenever text is changed . 我在表单中有一些
text boxes
,用户需要输入不同的商品价格,我想要做的就是每当文本更改时自动添加起始值*
。 So when the user types 1
it is displayed like *****1
and text box Length are 6
size fix. 因此,当用户键入
1
它会像*****1
一样显示,并且文本框“ Length”是6
大小固定值。 then again user type 111
it is display like ***111
然后再次用户输入
111
它显示像***111
You can use the PadLeft
method for a string: 您可以对字符串使用
PadLeft
方法:
textBox1.Text = textBox1.Text.PadLeft(6, '*');
See an example here: https://dotnetfiddle.net/GPfFsx 在此处查看示例: https : //dotnetfiddle.net/GPfFsx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.