2011-04-06 7 views
1

예 : "test"와 같은 텍스트 상자에서 3자를 가져와이 텍스트에서 3자를 얻으려고합니다.C# 텍스트 상자의 위치에서 문자 가져 오기

나는 printer1_logo.text가 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 

답변

3

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

인 당신은 단순히을 문자열을 사용할 수 있습니다

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

4

GetCharFomPosition (위치 좌표를 의미 문자 인덱스가 없습니다.) 당신은 또한 예를 들어 char 배열로 문자열을 사용할 수 :

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

B 당신이 필요로하는 경우 textBox1.Text = textBox2.Text(2).ToString

1 개 이상의 문자는 문자열에서 잘라합니다 :

string subString1 = textbox1.Text.Substring(0,3) 
관련 문제