开发者

Getting Char From Position in C# textbox

开发者 https://www.devze.com 2023-02-22 23:32 出处:网络
I\'m trying to get 3 character from textbox -> for example: \"test\" and get 开发者_运维百科3 from this text.

I'm trying to get 3 character from textbox -> for example: "test" and get 开发者_运维百科3 from this text.

I'm trying something like that where printer1_logo.text is another textbox where i'd like to have 4 character from textbox RefrenceNumber.

Printer1_Logo.Text=RefrenceNumber.GetCharFromPosition(4);

Errors:

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


In C# textBox1.Text = textBox2.Text[2].ToString()

In VB textBox1.Text = textBox2.Text(2).ToString

If you need more than 1 char

textBox1.Text = textBox2.Text.SubString(2,2)


GetCharFomPosition (Position means Coordinates. isn't char index) you can also use string as a char array for example :

Char  theChar = Printer1_Logo.Text[2]; // index is start at 0


You can simply use SubString to cut out from a string:

string subString1 = textbox1.Text.Substring(0,3)
0

精彩评论

暂无评论...
验证码 换一张
取 消