이 같이 할 수 ...
네,하지만 텍스트 상자 및 ListView를 다른 창에 내가 할 수없는 액세스 그것을 각 Form2를 드래그에서
다른 두 개의 텍스트 상자를 드롭 이렇게하십시오 ....
Form2를 표시하기 전에 Form2 클래스에 속성을 만들고 설정하십시오.
public class Form2
{
public string Name
{
get { return textbox1.Text; }
set { textbox1.Text = value; }
}
public string phonenumber
{
get { return textbox2.Text; }
set { textbox2.Text = value; }
}
}
public class Form1
{
private void btnedit_Click(object sender, eventargs e)
{
for (int i = 0; i < lv.Items.Count; i++)
{
// is i the index of the row you selected?
if (lv.Items[i].Selected == true)
{
//I show here the second field text (SubItems[1].Text) from the selected row(Items[i])
Message.Show(lv.Items[i].SubItems[1].Text);
break;
}
}
Form2 frm2 = new Form2();
frm2.Name= text1;
frm2.phonenumber = text2;
frm2.Show();
this.Hide(); //// if you want to hide the form1
}
}
}
나는
나는 그것을했고, 문제없이 컴파일하지만 편집 버튼을 쳤을 때 나는 '.... 그 것이다 당신을 도움이되기를 바랍니다 "InvalidArgument = '2'의 값이 'index'에 유효하지 않습니다 매개 변수 이름 : index"이 줄의 경우 '문자열 번호 = listView.SelectedItems [0] .SubItems [2] .Text; ' –
@ Владислав Найденов 나는 나의 대답을 편집했다 나의 대답을 보아라 –
고마워. 오류를 발견했습니다. SubItems 인덱스의 값을 변경하면 작동합니다. –