2

リスト ビューを詳細に設定して列を作成しようとしましたが、列が表示されません。列の表示を妨げているのは何ですか?

Imports System.IO
Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Menu


Public Class Jonathan_Roda_P4
    Dim TitlesData(21)
    Dim BOData(21)

    'Clear Button Function
    Private Sub ResetClearToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ResetClearToolStripMenuItem.Click
        'Clear Title LV
        DispResView.Clear()
        'Clear Box Office List
        BOList.Items.Clear()
        'Resets User Message to default
        UsrMsg.Text = "Data Not Loaded"
    End Sub

    'Help/Instructions Properties

    Private Sub InstructionsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InstructionsToolStripMenuItem.Click
        MessageBox.Show("1. Click the 'Load Files' Button" & vbNewLine _
                        & vbNewLine _
                        & "2. Select two respective files." & vbNewLine _
                        & "      (Note: Each file must have the same number of lines)" & vbNewLine _
                        & "      (Note: You may only select two files)" & vbNewLine _
                        & vbNewLine _
                        & "3. Select the 'Open' button to load your selected files" & vbNewLine _
                        & vbNewLine _
                        & "4. The Box Office Lister will now display each file's contents as it appears in the file" & vbNewLine _
                        & vbNewLine _
                        & "5. Clicking any of the sort buttons will reorder the displayed content as follows:" & vbNewLine _
                        & "       a) Sort by A-Z: Sorts the displayed content alphabetically by title" & vbNewLine _
                        & "       b) Sort by Z-A: Sorts the displayed content in reverse alphabetical order by title" & vbNewLine _
                        & "       c) Sort by 0-9: Sorts the displayed content in ascending numerical order by Box Office Amount" & vbNewLine _
                        & "       d) Sort by 9-0: Sorts the displayed content in descending numerical order by Box Office Amount" & vbNewLine _
                        & vbNewLine _
                        & "6. Clicking the 'Clear' button will reset the program and require you to select two new files" & vbNewLine _
                        & vbNewLine _
                        & "7. Clicking the 'Exit' button will close the program" & vbNewLine _
                        & vbNewLine _
                        & "8. TOP THIRD" & vbNewLine _
                        & "      Top Third lists the top 1/3 missions in order of Box Office Amount", "007 Box Office Lister Instructions")
    End Sub

    'File/Exit Properties
    Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Exit()
    End Sub

    'Exit Button Properties
    Private Sub ExitBtn_Click(sender As Object, e As EventArgs) Handles ExitBtn.Click
        Application.Exit()
    End Sub

    Private Sub ClearBtn_Click(sender As Object, e As EventArgs) Handles ClearBtn.Click
        DispResView.Clear()
        UsrMsg.Text = "Data Not Loaded"
    End Sub

    Private Sub LoadButton_Click(sender As Object, e As EventArgs) Handles LoadButton.Click

        With OpenFileDialog1
            .CheckPathExists = True
            .DefaultExt = "txt"
            .Filter = _
             "Text files (*.txt)|*.txt"
            .Multiselect = True
            .RestoreDirectory = True
            .Title = "Open"
            .ValidateNames = True
            DispResView.Clear()
        End With
        'Resets User Message to default if another message is displayed
        UsrMsg.Text = "Data Not Loaded"

        'Sets Default folder to Desktop
        OpenFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

        'OpenFileDialog Properties
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim count As Integer = 0
            For Each s As String In OpenFileDialog1.FileNames
                Dim sAllData() As String = System.IO.File.ReadAllLines(s)
                count = count + 1
            Next
            For Each openFile As String In OpenFileDialog1.FileNames
                Dim getAllData() As String = File.ReadAllLines(openFile)
                For i As Integer = 0 To getAllData.Length - 1
                    DispResView.Items.Add(getAllData(i))
                Next
            Next
        End If

    End Sub

    Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk

    End Sub
End Class
4

1 に答える 1

8

すべての列ヘッダーを ListView.Columns に追加しましたか? ListView は、ヘッダーがあるよりも多くの列を表示しません。

DispResView.Columns.Add "Name"
DispResView.Columns.Add "Size"
'etc.

列ヘッダーを消去したくない場合は、DispResview.Items.Clear代わりに を呼び出す必要があることに注意してくださいDispResView.Clear

于 2013-03-23T01:31:24.700 に答える