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

Add checkbox to form

Status
Not open for further replies.

manpaul

Technical User
Jan 10, 2005
118
CA
How do I add a checkbox to a form programmatically.

Depending on a varaible 1 - 9 I have to add a checkbox
1 = 1 checkbox,1 grid 9 = 9 checkboxes, and 9 grids to a form. The form exist. Depending on the variable I'll have to generate the following on enter of the form. Where is the best place and way to do this
Paul
 
Try this in the click method of the checkbox.

Brian

Code:
IF this.value=1
	Thisform.AddObject("grid1","grid")
	Thisform.AddObject("cbox1","checkbox")
	Thisform.grid1.Left=20
	Thisform.cbox1.Left=20
	Thisform.cbox1.Top=100
	Thisform.grid1.Visible=.t.
	Thisform.cbox1.Visible=.t.
ELSE
	Thisform.RemoveObject("grid1")
ENDIF
 
NINE Grids! WOW!

You could use form.AddObject() or form.NewObject() to add controls, just don't forget to Set .Visible = .t. to new added control. But 9 grids? Are you sure? :)
Create your own method something like:
AddControls(m.lnNumber) and invoke it from Init Event of the form: thisform.AddControls(3), that way you could invoke this method from everywhere if there you have access to forms methods.

Borislav Borissov
 

Paul,

Like Borislav, I'm surprised you have so many grids on a form. Obviously I don't know anything about your application, but it does seem that the form will be somewhat complex for the user. What exactly is the form doing?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
You are right after think about it (and reading your comments) I will have create the of check boxes required bases on the number then One grid with columns set to that number and this will work fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top