Posted By

nazslash on 12/01/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jaguilaru


listview


 / Published in: VB.NET
 

xphm

  1. Private Sub loadhostel()
  2. Dim AllRow As DataRow
  3. DAhostellist.Fill(Dsstudents1)
  4.  
  5. For i As Integer = 0 To Dsstudents1.STUDENT.Rows.Count - 1 Step 1
  6. AllRow = Dsstudents1.STUDENT.Rows(i)
  7.  
  8. If ComboBox1.SelectedItem.ToString = ValidateData(AllRow("hostelName")) And ComboBox2.SelectedItem.ToString = ValidateData(AllRow("hostelBlock")) Then
  9. AddNewLVRow(ListView1, AllRow)
  10. End If
  11. Next
  12. End Sub
  13. Private Sub AddNewLVRow(ByVal ListViewItm As ListView, ByVal xdataRow As DataRow)
  14. Dim itmparent As New ListViewItem(ValidateData(xdataRow("studentID")))
  15. Dim itm1 As New ListViewItem.ListViewSubItem(itmparent, ValidateData(xdataRow("hostelNo")))
  16. Dim itm2 As New ListViewItem.ListViewSubItem(itmparent, ValidateData(xdataRow("studentName")))
  17.  
  18. itmparent.SubItems.Add(itm1)
  19. itmparent.SubItems.Add(itm2)
  20.  
  21. ListViewItm.Items.Add(itmparent)
  22. End Sub
  23.  
  24. Private Function ValidateData(ByVal value As Object) As String
  25. If Not DBNull.Value.Equals(value) Then
  26. Return CStr(value)
  27. Else
  28. Return "-"
  29. End If
  30. End Function

Report this snippet  

You need to login to post a comment.