Hi Joe,

Here are some examples using different controls sources. 
There is also the Sorted property that can be used.
The Sorted property is only available if the RowSourceType property is set
to 0 (None) or 1 (Value).

HTH,
Tracy


    LOCAL testForm
    testForm = CREATEOBJECT("formClass")
    testForm.Show()

    DEFINE CLASS formClass as Form 
    
    WindowType = 1
    SelectedValue = 0
    
    ADD OBJECT AddComboBoxButton as CommandButton WITH Top = 10, Left = 10,
Caption = "Add Combobox 1"
    ADD OBJECT AddComboBoxButton2 as CommandButton WITH Top = 10, Left =
130, Caption = "Add Combobox 2"
    ADD OBJECT SelectedValueTextBox as TextBox WITH TOP = 10, Left = 260,
Width = 40, ControlSource = "THISFORM.SelectedValue"
    
    PROCEDURE AddComboBoxButton.Click
        THISFORM.AddComboBox()
    ENDPROC 
    
    PROCEDURE AddComboBoxButton2.Click
        THISFORM.AddComboBox2()
    ENDPROC 
    
    PROCEDURE SelectedValue_Assign
        LPARAMETERS newValue
        THISFORM.SelectedValue = newValue
        THISFORM.SelectedValueTextBox.Refresh()
    ENDPROC 
    
    PROCEDURE AddComboBox
        DEFINE POPUP ComboPopup FONT "Comic Sans MS", 16 
        DEFINE BAR 1 OF ComboPopup PROMPT "Option 1"
        DEFINE BAR 2 OF ComboPopup PROMPT "Option 2"
        DEFINE BAR 3 OF ComboPopup PROMPT "Option 3" STYLE "B" 
        DEFINE BAR 4 OF ComboPopup PROMPT "Option 4"

        IF TYPE("THISFORM.addedCombobox.Name") = "C"
            THISFORM.RemoveObject("addedCombobox")
        ENDIF 
        THISFORM.AddObject("addedCombobox", "Combobox")
        THISFORM.addedCombobox.Top = ThisForm.AddComboBoxButton.Top +
ThisForm.AddComboBoxButton.Height + 10
        THISFORM.addedCombobox.Left = 10
        THISFORM.addedCombobox.RowSourceType = 9
        THISFORM.addedCombobox.RowSource = "ComboPopup"
        THISFORM.addedCombobox.ControlSource = "THISFORM.SelectedValue"
        THISFORM.addedCombobox.Visible = .T.
        * THISFORM.addedCombobox.DropDown() && This didn't drop it down
        *-- This drops down the list
        THISFORM.addedCombobox.SetFocus()
        KEYBOARD '{ALT+DNARROW}'
    ENDPROC 
    
    PROCEDURE AddCombobox2
        CREATE CURSOR comboCursor (value c(20), id i)
        INSERT INTO comboCursor VALUES ("Option 1", 1)
        INSERT INTO comboCursor VALUES ("Option 2", 2)
        INSERT INTO comboCursor VALUES ("Option 3", 3)
        IF TYPE("THISFORM.addedCombobox.Name") = "C"
            THISFORM.RemoveObject("addedCombobox")
        ENDIF 
        THISFORM.AddObject("addedCombobox", "Combobox")
        THISFORM.addedCombobox.Top = ThisForm.AddComboBoxButton.Top +
ThisForm.AddComboBoxButton.Height + 10
        THISFORM.addedCombobox.Left = 10
        THISFORM.addedCombobox.RowSourceType = 2 
        THISFORM.addedCombobox.RowSource = "comboCursor"
        THISFORM.addedCombobox.BoundColumn = 2
        THISFORM.addedCombobox.ControlSource = "THISFORM.SelectedValue"
        THISFORM.addedCombobox.Visible = .T.
        * THISFORM.addedCombobox.DropDown() && This didn't drop it down
        *-- This drops down the list
        THISFORM.addedCombobox.SetFocus()
        KEYBOARD '{ALT+DNARROW}'
    ENDPROC

    ENDDEFINE


-----Original Message-----
From: ProfoxTech [mailto:profoxtech-boun...@leafe.com] On Behalf Of Joe
Yoder
Sent: Wednesday, June 26, 2024 8:19 PM
To: profoxt...@leafe.com
Subject: Combo box issues

I am looking for a way to have a combo box display its dropdown
programmatically. I want to do this to make it obvious that the user needs
to make a choice.  I have read that 'thisform.combobox.dropdown()' should
do the trick but the form comes up with the proper information in the
dropdown which can only be seen after clicking the control.

Another less important feature would be a way to control the position of
the list of choices when the dropdown is accessed.

Any help will be appreciated,

Joe


--- StripMime Report -- processed MIME parts ---
multipart/alternative
  text/plain (text body -- kept)
  text/html
---

[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: https://leafe.com/archives
This message: 
https://leafe.com/archives/byMID/00dd01dac893$ec5bae30$c5130a90$@powerchurch.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to