我尝试从文本框中获取3个字符,例如:“->”,然后从该文本中获取3个字符。
我正在尝试这样的东西,其中printer1_logo.text是另一个文本框,其中我希望从textbox RefrenceNumber中获得4个字符。
Printer1_Logo.Text=RefrenceNumber.GetCharFromPosition(4);
错误:
Argument 1: cannot convert from 'int' to 'System.Drawing.Point' (CS1503) - D:\App\MainForm.cs:249,66
The best overloaded method match for 'System.Windows.Forms.TextBoxBase.GetCharFromPosition(System.Drawing.Point)' has some invalid arguments (CS1502) - D:\App\MainForm.cs:249,31
发布于 2011-04-06 09:44:57
在C# textBox1.Text = textBox2.Text[2].ToString()
中
在VB textBox1.Text = textBox2.Text(2).ToString
中
如果需要1个以上的字符
textBox1.Text = textBox2.Text.SubString(2,2)
发布于 2011-04-06 09:43:56
GetCharFomPosition (位置表示坐标。不是char索引),也可以使用string作为char数组,例如:
Char theChar = Printer1_Logo.Text[2]; // index is start at 0
发布于 2011-04-06 10:14:04
您可以简单地使用SubString从字符串中剪切:
string subString1 = textbox1.Text.Substring(0,3)
https://stackoverflow.com/questions/5564319
复制相似问题