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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

property of textboxes 1

Status
Not open for further replies.

and0b

MIS
Mar 27, 2007
51
US
I need advice on changing few textboxes properties at once. I have 10 textboxes: textbox1, textbox2,..... textbox10. How can I change width of textbox2, textbox4, textbox5, textbox7 and texbox9 at once? Can I somehow replace # with variable in MyForm.textbox3.width=150

Thank you!
 
>How can I change width of textbox2, textbox4, textbox5, textbox7 and texbox9 at once? Can I somehow replace # with variable in MyForm.textbox3.width=150

At design time: You can do this in the visual designer by select all the text boxes (either lassoo, or shift+click) and set the property. When you have multiple objects selected the property sheet only shows properties that all have in common - so setting the width will affect all selected items.

At run time there is really no way to pick and choose - as Mike said you can use ThisForm.Setall() but that really does set all objects of the specified class (note, the class specified may be a custom sub-class, it doesn't have to be a base class).

----
Andy Kramek
Visual FoxPro MVP
 
Thanks, I figured it out. Here it is:

par='3'

MyForm.textbox&par..width=150

I don't have idea why there have to be two dots.


Andrew
 
>>MyForm.textbox&par..width=150
>> I don't have idea why there have to be two dots.

Because a dot terminates macro expansion. If you need a dot in the expansion code you need to double it (just like an embedded "'" in T-SQL has to be sent as "''".

Without the double do the line would expand to "MyForm.textbox3"

i.e. the ".width" would be lost and you would get a syntax error.




----
Andy Kramek
Visual FoxPro MVP
 
Code:
local lnTxtBox,lcWith
for lnTxtBox=1 to 10
  lcWith='thisform.TextBox'+alltrim(str(lnTxtBox))
  with &lcWith
    .width=150
  endwith
endfor


Andy Snyder
SnyAc Software Services
 
Code:
for lnI = 1 to 10
  store myNewWidthValue to ('thisform.textbox' + transform(m.lnI) + ".width")
next
 
Hi and0b

Think also about using a Command Group control, instead of 10 individual Commands buttons. (Command Group is normally included in Form controls toolbars.)

You can access Buttons from the group individually or all of them at once.
Changing the width means nothing more then one command

Code:
ThisForm.Commandgroup1.Width = lnSomeValue

Still you can make – for example - the third button smaller with
Code:
ThisForm.Commandgroup1.Button3.Width = lnSomeValue - 10

Sometimes could be handy.

Tom.
 
Hi and0b and all the others

Sorry for unsuitable information. I am overworked probably – if not something worse.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top