|
(1)布局文件
- <ListView x:Name="ListView1" HorizontalAlignment="Left" Height="360" Margin="0,82,0,0" VerticalAlignment="Top" Width="772" Grid.ColumnSpan="4" BorderThickness="0">
- <ListView.View>
- <GridView>
- <GridViewColumn Header="文件夹名" Width="200" DisplayMemberBinding="{Binding Path=fold_name}"/>
- <GridViewColumn Header="文件夹路径" Width="300" DisplayMemberBinding="{Binding Path=fold_path}"/>
- <GridViewColumn Header="图标" Width="130" DisplayMemberBinding="{Binding Path=fold_icon}"/>
- <GridViewColumn Header="加密时间" Width="170" DisplayMemberBinding="{Binding Path=do_time}"/>
- </GridView>
- </ListView.View>
- </ListView>
复制代码
(2)绑定数据库resource
- ListView1.Width = Me.Width
- Dim da As OleDbDataAdapter = New OleDbDataAdapter("select * from fold order by id desc", conn)
- Dim ds As New DataSet
- da.Fill(ds, "fold")
- ListView1.Items.Clear()
- If ds.Tables.Count > 0 Then
- For i = 0 To ds.Tables(0).Rows.Count - 1
- Dim dr = ds.Tables(0).Rows(i)
- ListView1.Items.Add(New DataItem(dr.ItemArray(1).ToString, dr.ItemArray(2).ToString, dr.ItemArray(3).ToString, dr.ItemArray(4).ToString))
- Next
- End If
复制代码
(3)collection item类定义
- Public Class DataItem
- Private _fold_name As String
- Public Property fold_name() As String
- Get
- Return _fold_name
- End Get
- Set(value As String)
- _fold_name = value
- End Set
- End Property
- Private _fold_path As String
- Public Property fold_path() As String
- Get
- Return _fold_path
- End Get
- Set(value As String)
- _fold_path = value
- End Set
- End Property
- Private _fold_icon As String
- Public Property fold_icon() As String
- Get
- Return _fold_icon
- End Get
- Set(value As String)
- _fold_icon = value
- End Set
- End Property
- Private _do_time As String
- Public Property do_time() As String
- Get
- Return _do_time
- End Get
- Set(value As String)
- _do_time = value
- End Set
- End Property
- Public Sub New(ByVal fpath As String, ByVal fname As String, ByVal ficon As String, ByVal dotime As String)
- Me.fold_icon = ficon
- Me.fold_name = fname
- Me.fold_path = fpath
- Me.do_time = dotime
- End Sub
- End Class
复制代码
效果图
|
|