Alberto Garcia Cano
Alberto Garcia Cano

Reputation: 3

How to add a user defined control to a form in VFP

Hi: I have created a very simple user defined control (a container) with the visual IDE of Visual Foxpro 9 and stored it into a VCX file (sisweb.vcx)

After that I've created (visually) a form and in the INIT event I've tried to instantiate the previous container control and add to the form:

oContainer=newobject("xContainer","sisweb.vcx")
ThisForm.AddObject("Contx","oContainer")
ThisForm.Contx.Width=230

Unfortunatelly, when trying to ADD the container object, it rises an error saying that oContainer doesn't exists.

Can you help me please?

Upvotes: 0

Views: 2670

Answers (1)

Stefan Wuebbe
Stefan Wuebbe

Reputation: 2149

When you want to add an object dynamically at run-time, you could do something like

Thisform.NewObject("Contx", "xContainer", "sisweb.vcx")
Thisform.Contx.Width = 230
Thisform.Contx.Visible = .T.

Where assigning the Visible property explicitly is important.

On the other hand, you could also add it "visually" in the Designer by dragging it from the Project Manager's "Classes" tab, or by using the bookshelf icon of the Form / Class Designer's "Controls" toolbar, or the "Toolbox" in the "Tools" menu

Upvotes: 2

Related Questions