Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find items in a list view control..

Status
Not open for further replies.

Redsz

Programmer
Jul 30, 2002
158
CA
what would be the best way to iterate through a listview control checking the listitem.text property?

for ncnt = 1 to ListView.listitems()?????

Or is there a way to count the listview items like a list box has with listcount() ?
 
Redsz
Listcount . Same

Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
	Top = 0
	Left = 0
	Height = 294
	Width = 375
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
       ADD OBJECT list1 AS listbox WITH ;
		RowSourceType = 1, ;
		RowSource = "Hello,Hello1,hello3", ;
		Height = 181, ;
		Left = 60, ;
		Top = 36, ;
		Width = 253, ;
		Name = "List1"
	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 252, ;
		Left = 144, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Command1", ;
		Name = "Command1"
	PROCEDURE command1.Click
		MESSAGEBOX("There are "+TRANSFORM(thisform.list1.ListCount) +" items in this list")
	ENDPROC
ENDDEFINE

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first or check this link
 
thx mgagnon. Now another question.

In the itemclick event how would i return subitems(3).text ?

test = thisform.lstlookup.subitems(3).text
 
Redsz

Once selected it becomes the value of the listbox.

Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
        DoCreate = .T.
	Caption = "Form1"
	Name = "form1"
	ADD OBJECT list1 AS listbox WITH ;
		RowSourceType = 1, ;
		RowSource = "hello,hello1,hello2", ;
		Height = 205, ;
		Left = 48, ;
		Top = 12, ;
		Width = 265, ;
		Name = "List1"
	PROCEDURE list1.Click
		  MESSAGEBOX(thisform.list1.value )
	ENDPROC
ENDDEFINE
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first or check this link
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top