Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Looping through option group control
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01302955
Message ID:
01302977
Vues:
14
>>I am trying to loop through option group control and set the option buttons .Left value based on whether the control is visible or not; however, I can't seem to get the values or set the values of the option button. I use an array that has the location value for the .left property. Basically, I'm trying to move the option button to left if the option button is visible. I'm missing something or is there a better way.
>>
>>
>>WITH thisform
>>	LOCAL visible_val, loopcnt, arraycnt
>>	visible_val = '' && hold visible value of option button
>>	loopcnt = 1 && loop counter
>>	arraycnt = && array counter
>>
>>	DIMENSION gaMyArray(1,5)
>>	gaMyArray(1,1) = 5
>>	gaMyArray(1,2) = 54
>>	gaMyArray(1,3) = 125
>>	gaMyArray(1,4) = 237
>>	gaMyArray(1,5) = 345						
>>	DO WHILE loopcnt <= 5  && have 5 option buttons in optiongroup
>>		
>>		visible_val = thisform.+"Optiongroup1.option"+loopcnt+".visible"
>>		IF visible_val = .t.
>>			arraycnt = arraycnt + 1
>>			thisform.+"Optiongroup1.option"+loopcnt+".left" = gaMyArray(1,arraycnt)  && sets the next .left value
>>		ENDIF
>>		loopcnt = loopcnt + 1
>>	ENDDO
>>ENDWITH
>>
>>
>>thanks
>>Nick
>
>Can you just use for each instead?
>
>E.g.
>for each loOption in thisform.OptionGroup1.Buttons
>   if loOption.visible = .t.
>      loOption.left =
>  endif
>next
Hi Naomi, thanks for replying back. Never really used a for...each before. I tried the following:
	arraycnt = 1 && array counter
	DIMENSION gaMyArray(1,5)
	gaMyArray(1,1) = 5
	gaMyArray(1,2) = 54
	gaMyArray(1,3) = 125
	gaMyArray(1,4) = 237
	gaMyArray(1,5) = 345	
	
	for each loOption in thisform.optiongroup1.Buttons
   		if loOption.visible = .t.
	     	   loOption.left = gaMyArray(1,arraycnt)
	     	   arraycnt = arraycnt + 1 
  		endif
	next
but it says:
Unknown Member OPTIONGROUP1
optiongroup1 control is on my form.

thanks
Nick
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform