因此,当我单击一个按钮时,我需要制作一个程序来显示公司三个不同领域的月销售额和总计。我添加了此代码,但似乎无法正确处理。有人可以建议我如何解决它。另外,加载表单时,我的标题“省,百分比,贡献等”也不会显示在列表框中。
所以基本上我的.txt文件中的值如下:
1,夸祖鲁·纳塔尔,44,1200001,豪登省,33,9000001,西开普省23,650002,夸祖鲁纳塔尔,56,1900002,豪登省,25,850002,西开普省,19,640003,夸祖鲁纳塔尔,54,1750003,豪登省,25,80000西开普省3,21,710004,夸祖鲁纳塔尔,55,1880004,豪登省,25,830004,西开普省20,670005,夸祖鲁纳塔尔46,1250005,豪登省,31,870005,西开普省23,650006,夸祖鲁纳塔尔,53,1630006,豪登省,26,800006,Western Cape,21,64000
现在,他们应该每月在标题下显示(1-6)。当我运行代码时,它们不会显示标题,而只会显示地点名称。它不会给出错误
Imports System.IO
Public Class FormMain
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
resultsBox.Items.Clear()
resultsBox.Columns.Add("Province", 100, HorizontalAlignment.Center)
resultsBox.Columns.Add("Percentage", 100, HorizontalAlignment.Center)
resultsBox.Columns.Add("Contribution", 100, HorizontalAlignment.Center)
resultsBox.Columns.Add("Total Cost", 100, HorizontalAlignment.Center)
End Sub
Private Sub ExitBtn_Click(sender As Object, e As EventArgs) Handles ExitBtn.Click
Me.Close()
End Sub
Private Sub ShowResultsBtn_Click(sender As Object, e As EventArgs) Handles ShowResultsBtn.Click
Dim salesReport As String = MonthlyCBox.Text
Dim filereader As New StreamReader("C:\Users\HP Notebook 15\Desktop\main.txt")
Dim details As Array
Dim provinceFound As String = " "
Dim percentageContribute As Integer = 0
Dim monthlySales As Integer = 0
Dim totalvalue As Integer = 0
While filereader.EndOfStream = False
details = filereader.ReadLine().Split(",")
Dim province As String = details(1)
Dim percentage As Decimal = details(2)
Dim monthlyammount As String = details(3)
Dim totalamm As String = details(3)
If details(0) = salesReport Then
resultsBox.Items.Add(New ListViewItem({province, percentage, FormatCurrency(monthlyammount), FormatCurrency(totalamm)}))
End If
End While
End Sub
End Class
我想您正在使用ListView,而不是List Box。如果是这样,请添加resultsBox.View = View.Details
,在加载事件中。那应该可以看到标题文本。