PRA KATA
Starting...
Buatlah project baru, tambahkan pada form sebuah Listview, Button, dan TextBox, bagaimana mengatur komponen tersebut agar menarik... itu menjadi urusan Kamu.. aturlah sesuai selera kamu.. ok
Codenya..
Kemudian Copy code berikut ini...
Private Sub ResettingListView()
With ListView1
.Clear()
.View = View.Details
.GridLines = True
.FullRowSelect = True
.Columns.Add("Col", 100, HorizontalAlignment.Left)
.Columns.Add("Desc", 300, HorizontalAlignment.Left)
End With
End Sub
Private Sub ListViewMakeRow(ByVal lvw As ListView, ByVal item_title As String, ByVal ParamArray subitem_titles() As String)
Dim new_item As ListViewItem = lvw.Items.Add(item_title)
For i As Integer = subitem_titles.GetLowerBound(0) To subitem_titles.GetUpperBound(0)
new_item.SubItems.Add(subitem_titles(i))
Next i
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xCount As Integer = 0
Call ResettingListView()
For xCount = 0 To 20
Call ListViewMakeRow(ListView1, xCount.ToString, "Ini " & xCount.ToString)
Next
End Sub
Private Sub CariDiListView(ByVal Text2Search As String)
Try
Dim foundItem As ListViewItem = _
ListView1.FindItemWithText(Text2Search, True, 0, True)
ListView1.SelectedItems.Clear()
If Not (foundItem Is Nothing) Then
ListView1.Focus()
foundItem.Selected = True
ListView1.TopItem = foundItem
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Call CariDiListView(TextBox1.Text)
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK)
End Try
End Sub
Finally....
Selesai deh... selamat mencoba, semoga bermanfaat.
Sumber...
1. MSDN Offline
Tidak ada komentar:
Posting Komentar