2016-09-21 1 views
0

내 목표를 작동하지 않는 것은 다음과 같다 : The user enters the stuff as shown in this picture. The 3 items (source file, destination directory and if file exists) are saved in a string array. User clicks OK.동적으로 ListView를 열 문자열을 표시 -

After clicking OK the previous window is closed and the user is taken to the main form shown in this picture. The previously mentioned source file and the destination directory are shown in the table.

나는 테이블의 입력 파일 & 디렉토리 보여주기 위해 다음 코드를 사용하고 있습니다 :

private void okButton_Clicked(object sender, EventArgs e) 
    { 
     //saving user's input 
     userInput = new string[3]; 
     userInput[0] = sourceFileTextBox.Text; 
     userInput[1] = destinationDirComboBox.SelectedItem.ToString(); 
     userInput[2] = ifFileExistsComboBox.SelectedItem.ToString(); 

     //creating a new ListView object - the object is derived from the ListView Class 
     and has absolutely nothing in the constructor or anywhere 
     Classes.ListViewDerivative lvd = new Classes.ListViewDerivative(); 
     ListViewItem item1 = new ListViewItem(userInput[0]); 
     item1.SubItems.Add(userInput[1]); 
     lvd.Items.AddRange(new ListViewItem[] { item1 }); 
     this.DialogResult = DialogResult.OK; 
     this.Hide(); 
    } 

작동하지 않습니다. 이 코드를 어디에 넣든 테이블이 비어 있습니다. ListViewDerivative 생성자, ListViewDerivative 클래스의 함수 및 editFileEntry (첫 번째 그림) 클래스에이 적응 코드를 넣으려고했습니다. 오른쪽 텍스트는 배열에 저장되지만 표에는 표시되지 않습니다. 도와주세요!

+0

당신이 당신의 ListView에 필요한 열을 추가 했습니까? – TaW

답변

0

lvd 변수가 사용되지 않았습니다. 메인 뷰에 'lvd'컨트롤을 추가해야합니다. 당신은 이것을 위해 Designer를 사용할 수 있으며 "FilePickerDialog"의 Dialog Result에서 결과를 DataGrid에 할당 할 수 있습니다.

당신의 MAINVIEW에 대한 몇 가지 의사 코드

void Config_Clicked() 
{ 
    ConfigDlg dlg = new ConfigDlg(); 
    if(dlg.ShowDialog() == OK) 
    { 
     this.myListView1.Items.Add(dlg.userInput[0]); 
    } 
} 
+0

고마워요. 그것은 효과가 있었다. – Dovile

+0

듣고 좋은 ;-) 나는 내 모든 의사 코드에서 그것을 기대하지 않을 것이다 ^^ – Mat