List View Q

G

Guest

I have a textbox that holds a product code called txtDtlProdCode.Tex
I insert the values into SQLCE and populate a list view lstOrdersDt
I then check to see that the product code in txtDtlProdCode.Text is in lstOrdersDtl and throw a message if it exists
I then want to find and set the lstOrderDtl.FullRowSelect to the particular item in lstOrdersDtl. I want to do this without a DB Call. Can I

Have tried..

For Each lvi As ListViewItem In lstOrderDtl.Item

If lvi.Text = txtDtlProdCode.Text The
MessageBox.Show("marc"
MessageBox.Show(lvi.Text
MessageBox.Show(txtDtlProdCode.Text
lvi.Selected = Tru
Exit Fo
End I

Nex

and ....

For Each lvi As ListViewItem In lstOrderDtl.Item

If lvi.Text = txtDtlProdCode.Text The
lvi.Selected = Tru
End I

Dim bool As Boolean = lstOrderDtl.SelectedIndices.Count >
Nex

But lvi.Text is an index, and txtDtlProdCode.Text is a string and i need to compare them as above
How can i get the ListView entries(it is a product code (eg) 190365) from the relevant subitem to compare with my TextBox (which is also a product code (eg) 190365)? can it be done? i cannot seem to find right method/
 
A

Alex Feinman [MVP]

If your value is in e.g. subitem 2, compare that subitem with the content of
your edit control:

If lvi.Subitems(2).Text = txtDtlProdCode.Text Then
lvi.Selected = True
End If

--
Alex Feinman
---
Visit http://www.opennetcf.org
Marc McGuckian said:
I have a textbox that holds a product code called txtDtlProdCode.Text
I insert the values into SQLCE and populate a list view lstOrdersDtl
I then check to see that the product code in txtDtlProdCode.Text is in
lstOrdersDtl and throw a message if it exists.
I then want to find and set the lstOrderDtl.FullRowSelect to the
particular item in lstOrdersDtl. I want to do this without a DB Call. Can I?
Have tried...

For Each lvi As ListViewItem In lstOrderDtl.Items

If lvi.Text = txtDtlProdCode.Text Then
MessageBox.Show("marc")
MessageBox.Show(lvi.Text)
MessageBox.Show(txtDtlProdCode.Text)
lvi.Selected = True
Exit For
End If

Next

and .....

For Each lvi As ListViewItem In lstOrderDtl.Items

If lvi.Text = txtDtlProdCode.Text Then
lvi.Selected = True
End If

Dim bool As Boolean = lstOrderDtl.SelectedIndices.Count > 0
Next

But lvi.Text is an index, and txtDtlProdCode.Text is a string and i need to compare them as above.
How can i get the ListView entries(it is a product code (eg) 190365) from
the relevant subitem to compare with my TextBox (which is also a product
code (eg) 190365)? can it be done? i cannot seem to find right method/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top