Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Russell Hill
  Where is Russell Hill?
 Sydney
 Australia
 Russell Hill
 Tags
Subject: RE: ListBox InteractiveChange
Thread ID: 209399 Message ID: 209422 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Sunday, December 28, 2008 2:36:41 PM         
   


> Hi all,
>
> I have a ListBox with MoverBars = .T.
>
> Using help I recently received from Anders, I am looping through the ListBox items in the InteractiveChange event:
>
>
lbobj = This
> many_items = lbobj.ListCount
> items_string = ''
> FOR loop=1 TO many_items
>     items_string = items_string + '~' + lbobj.List(loop,1)
> NEXT
> MESSAGEBOX(items_string)

> Now when I move an item in the ListBox to somewhere else I see the correct MESSAGEBOX detail but I see it twice.
>
> Based on items_string, I want to do some SQL UPDATE stuff to a table to be used for a Grid definition but I'd rather do it just once.
>
> Does anyone know why the InteractiveChange event is firing twice in this situation?
>

I don't, but as a guess, internally both events might be considered as an interactive change, first when the moved item is clicked before the drag operation, then when it is dropped and the listbox.value changes again.

> If so, what is the remedy?
>

Comparing old and new value seems to work:

CLEAR

LOCAL oForm as Form
oForm = CREATEOBJECT('TestForm')
oForm.Show(1)
RETURN

DEFINE CLASS TestForm as Form
	AutoCenter = .T.
	AllowOutput = .F.
	dummy = 1
*!*		PROCEDURE dummy_assign(newValue)
*!*			? LOWER(PROGRAM())	&& runs twice on item move
*!*			IF m.newValue <> Thisform.dummy
*!*				? m.newValue
*!*			ENDIF
*!*			Thisform.dummy = m.newValue
*!*		ENDPROC

	ADD OBJECT List1 as Listbox WITH ;
		Left = 50, Top = 50, MoverBars = .T., ;
		ControlSource = 'Thisform.dummy'
	PROCEDURE List1.Init
		This.AddItem('One')
		This.AddItem('Two')
		This.AddItem('Three')
	ENDPROC
	PROCEDURE List1.InterActiveChange()
		? LOWER(PROGRAM())	&& runs twice on item move
		IF This.Value <> EVALUATE(This.ControlSource)
			? 'conditional InterActiveChange runs once only'
		ENDIF
	ENDPROC
	PROCEDURE List1.Valid()
*!*			? LOWER(PROGRAM())  && does not run at all on item move
	ENDPROC
	PROCEDURE List1.When()
*!*			? LOWER(PROGRAM())	&& runs twice on item move
	ENDPROC

ENDDEFINE



hth
-Stefan

ENTIRE THREAD

ListBox InteractiveChange Posted by Russell Hill @ 12/28/2008 11:24:38 AM
RE: ListBox InteractiveChange Posted by Stefan Wuebbe @ 12/28/2008 2:36:41 PM
RE: ListBox InteractiveChange Posted by Russell Hill @ 12/29/2008 12:44:11 PM
RE: ListBox InteractiveChange Posted by tushar @ 12/28/2008 3:38:30 PM
RE: ListBox InteractiveChange Posted by Russell Hill @ 12/29/2008 12:43:35 PM
RE: ListBox InteractiveChange Posted by Yousfi Benameur @ 12/28/2008 7:49:26 PM
RE: ListBox InteractiveChange Posted by Russell Hill @ 12/29/2008 12:42:57 PM