0
내 문제는 텍스트 상자 객체에 값을 쓸 수 없다는 것입니다.배열에 저장된 텍스트 상자에 값을 쓰는 것
private void addHochpunkt(float xValue, float yValue)
{
int i;
for (i = 0; i < 10; i++)
{
if (!(string.IsNullOrWhiteSpace(arrayTextBoxenHochpunkte[i,1].Text)))
{
continue;
}
arrayTextBoxenHochpunkte[i, 1].Text = "xValue";
arrayTextBoxenHochpunkte[i, 2].Text = "yValue";
}
}
내가 잘못 뭐하는 거지 : 여기
int number = 10;
TextBox[,] arrayTextBoxenHochpunkte= new TextBox[10,3];
for(int i=0; i<number; i++)
{
TextBox newTextBox = new TextBox();
newTextBox.Location = new Point(0, (3+(i * 25)));
newTextBox.Size = new Size(25, 26);
newTextBox.Text = "H" + Convert.ToString(i + 1);
newTextBox.ReadOnly = true;
panel1.Controls.Add(newTextBox);
arrayTextBoxenHochpunkte[i, 0] = newTextBox;
TextBox newTextBox2 = new TextBox();
newTextBox2.Location = new Point(28, (3+(i * 25)));
newTextBox2.Size = new Size(50, 26);
newTextBox2.ReadOnly = true;
panel1.Controls.Add(newTextBox2);
arrayTextBoxenHochpunkte[i, 1] = newTextBox2;
TextBox newTextBox3 = new TextBox();
newTextBox3.Location = new Point(83, (3+(i * 25)));
newTextBox3.Size = new Size(50, 26);
newTextBox3.ReadOnly = true;
panel1.Controls.Add(newTextBox3);
arrayTextBoxenHochpunkte[i, 2] = newTextBox3;
}
이 텍스트 상자에 값을 작성해야하는 방법입니다 : 여기 는 텍스트 상자가 생성 된 코드의 일부이다?
변화'' "가 xValue을"''사용하려고하면 지방의 하나로서, 유명한 NullReferenceException이 트리거 글로벌 빈 떠나 초기화 문자열로 변환하려고합니다. –
배열을 전역 적으로 선언 했습니까? 위의 코드는 텍스트 상자의 로컬 배열을 사용하는 것 같습니다. – Steve
당신은 모든 값을 사용하지 않고''xValue yValue ''의 문자열 값을 다음과 같이 지정해야합니다. 'arrayTextBoxenHochpunkte [i, 1] .Text = xValue.ToString(); arrayTextBoxenHochpunkte [i, 2] .Text = yValue.ToString();'값 변환 사용법을 이해해야합니다. – MethodMan