Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- For ist As Integer = 0 To LVNewBill.Items.Count - 1
- LVNewBill.Items(ist).Selected = False
- Next
- For i As Integer = 0 To LVNewBill.Items.Count - 1
- 'If LVNewBill.Items(i).SubItems(0).Text.Contains(str) Then
- If LVNewBill.Items(i).Text.Contains(InsertChange) Then
- LVNewBill.Items(i).Selected = True
- LVNewBill.Items(i).EnsureVisible()
- 'If the Record Found it will Update
- With Me.LVNewBill.SelectedItems(0).SubItems
- '.Item(0).Text = txtrefcode.Text
- .Item(1).Text = txtdetails.Text
- .Item(2).Text = txtperiod.Text
- .Item(3).Text = txtduedate.Text
- Dim newtxtamt As Double = txtamt.Text
- .Item(4).Text = newtxtamt.ToString("###,###,##0.#0")
- End With
- Else
- ' add to lvmain
- End If
- Next
- private void init()
- {
- listView1.Items.Add(new ListViewItem() { Content = "Hi" });
- listView1.Items.Add(new ListViewItem() { Content = "Hello"});
- listView1.Items.Add(new ListViewItem() { Content = "Buy" });
- }
- private bool find(string str)
- {
- foreach (ListViewItem item in listView1.Items)
- {
- if (item.Content.Equals(str))
- {
- return true;
- }
- }
- return false;
- }
- private void select(string str)
- {
- foreach (ListViewItem item in listView1.Items)
- {
- if (item.Content.Equals(str))
- {
- item.IsSelected = true;
- }
- else
- {
- item.IsSelected = false;
- }
- }
- }
- private void onSelectedClickHandler(object sender, RoutedEventArgs e)
- {
- if (find(searchTextBox.Text))
- {
- select(searchTextBox.Text);
- }
- else
- {
- MessageBox.Show("Not found");
- }
- }
- var qry = from t in LVNewBill.Items
- where t.Text.Contains(InsertChange)
- select t;
- foreach(var item in qry)
- {
- item.Selected = true;
- item.EnsureVisible();
- item.SubItems[1].Text = txtdetails.Text;
- item.SubItems[2].Text = txtperiod.Text;
- item.SubItems[3].Text = txtduedate.Text;
- //Might want to consider TryParse here
- double newtxtamt = double.Parse(txtamt.Text);
- item.SubItems[4].Text = newtxtamt.ToString("###,###,##0.#0");
- }
Add Comment
Please, Sign In to add comment