I have been trying to come up with simple code to let me generate and configure ComboBoxes in code. I have succeeded in creating one combo and controlling its top and left properties by passing parameters but when I try to pass in a name things don't work. Here is the procedures code in a file named Try:
* Procedure to create a form PROCEDURE CreateForm PUBLIC oForm oForm = CREATEOBJECT("Form") oForm.Caption = "My Form" oForm.Show() ENDPROC
* Procedure to add a ComboBox to the form PROCEDURE AddComboBoxToForm(toForm, nTop, nLeft, cname) LOCAL oComboBox oComboBox = CREATEOBJECT("ComboBox") oComboBox.AddItem("Item 1") oComboBox.AddItem("Item 2") * toForm.AddObject("oComboBox", (cname)) toForm.oComboBox.name = cname toForm.oComboBox.Top = nTop toForm.oComboBox.Left = nLeft toForm.oComboBox.Visible = .T. ENDPROC
The code that calls it in a file named Joe follows:
* Call the procedures from the first file DO try && load the procedures
* Create a form CreateForm()
* Add a ComboBox to the form at position (40, 40) AddComboBoxToForm(oForm, 40, 40, "oComboBox1")
* Add a second ComboBox to the form at position (80, 80) AddComboBoxToForm(oForm, 80, 80, "oComboBox2")
I have been working with CoPilot to generate the code but it keep telling me that I need to create a custom class using the visual tools. I would appreciate a second opinion from real experts!
Thanks in advance, Joe
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---