Guest User

Untitled

a guest
Jan 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. For ist As Integer = 0 To LVNewBill.Items.Count - 1
  2. LVNewBill.Items(ist).Selected = False
  3. Next
  4.  
  5. For i As Integer = 0 To LVNewBill.Items.Count - 1
  6. 'If LVNewBill.Items(i).SubItems(0).Text.Contains(str) Then
  7. If LVNewBill.Items(i).Text.Contains(InsertChange) Then
  8. LVNewBill.Items(i).Selected = True
  9. LVNewBill.Items(i).EnsureVisible()
  10.  
  11. 'If the Record Found it will Update
  12.  
  13. With Me.LVNewBill.SelectedItems(0).SubItems
  14. '.Item(0).Text = txtrefcode.Text
  15. .Item(1).Text = txtdetails.Text
  16. .Item(2).Text = txtperiod.Text
  17. .Item(3).Text = txtduedate.Text
  18. Dim newtxtamt As Double = txtamt.Text
  19. .Item(4).Text = newtxtamt.ToString("###,###,##0.#0")
  20. End With
  21. Else
  22. ' add to lvmain
  23. End If
  24. Next
  25.  
  26. private void init()
  27. {
  28. listView1.Items.Add(new ListViewItem() { Content = "Hi" });
  29. listView1.Items.Add(new ListViewItem() { Content = "Hello"});
  30. listView1.Items.Add(new ListViewItem() { Content = "Buy" });
  31. }
  32.  
  33. private bool find(string str)
  34. {
  35. foreach (ListViewItem item in listView1.Items)
  36. {
  37. if (item.Content.Equals(str))
  38. {
  39. return true;
  40. }
  41. }
  42.  
  43. return false;
  44. }
  45.  
  46. private void select(string str)
  47. {
  48. foreach (ListViewItem item in listView1.Items)
  49. {
  50. if (item.Content.Equals(str))
  51. {
  52. item.IsSelected = true;
  53. }
  54. else
  55. {
  56. item.IsSelected = false;
  57. }
  58. }
  59. }
  60.  
  61. private void onSelectedClickHandler(object sender, RoutedEventArgs e)
  62. {
  63. if (find(searchTextBox.Text))
  64. {
  65. select(searchTextBox.Text);
  66. }
  67. else
  68. {
  69. MessageBox.Show("Not found");
  70. }
  71. }
  72.  
  73. var qry = from t in LVNewBill.Items
  74. where t.Text.Contains(InsertChange)
  75. select t;
  76.  
  77. foreach(var item in qry)
  78. {
  79. item.Selected = true;
  80. item.EnsureVisible();
  81. item.SubItems[1].Text = txtdetails.Text;
  82. item.SubItems[2].Text = txtperiod.Text;
  83. item.SubItems[3].Text = txtduedate.Text;
  84.  
  85. //Might want to consider TryParse here
  86. double newtxtamt = double.Parse(txtamt.Text);
  87. item.SubItems[4].Text = newtxtamt.ToString("###,###,##0.#0");
  88. }
Add Comment
Please, Sign In to add comment