
VB.net listview的用法大神们帮帮忙
我想使用vb.net将txt文件中的全部内容逐行添加到listview中代码如下ImportsSystem.IOPublicClassForm2DimstrAsStrin...
我想使用vb.net将txt文件中的全部内容逐行添加到listview中 代码如下 Imports System.IO Public Class Form2 Dim str As String Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListView1.View = View.List ListView1.FullRowSelect = True OpenFileDialog1.Filter = "所有文件(*.*)|*.*|对码文件(*.txt)|*.txt|入库文件(*.dat)|*.dat" OpenFileDialog1.FilterIndex = 2 OpenFileDialog1.ShowDialog() TextBox1.Text = OpenFileDialog1.FileName str = OpenFileDialog1.FileName Dim fs As FileStream = New FileStream(TextBox1.Text, FileMode.OpenOrCreate, FileAccess.Read) Dim sr As StreamReader = New StreamReader(fs) While (str) <> Nothing str = sr.ReadLine() ListView1.Items.Add(str) End While fs.Close() sr.Close() End Sub End Class 可以添加出来的效果是向右添加的 如何才能一直向下添加呢
展开
1个回答
展开全部
在form_load事件里控制列应该就可以向下添加了 ListView1.Columns.Add("列名", ListView1.Width) ListView1.View = View.Details
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询