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 ---
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-bounces@leafe.com] On Behalf Of Joe Yoder Sent: Wednesday, June 26, 2024 8:19 PM To: profoxtech@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]
Hi Joe,
just to correct your misunderstanding: DROPDOWN() is an event, not a method. Notice that yellow "flash" icon in the propertysheet? Events happen to you; methods are thrown by you (hence that flying green rubber as icon). That's why you can't use events like Dropdown (or Click etc) to do anything useful, it just signals you that a DropDown happened.
Now to your problem: Use the event that fires when the combobox gets entered: GOTFOCUS, and here you just do a simple: KEYBOARD "{ALT+DnArrow}" PLAIN CLEAR
And Viola: the dropdown list appears.
wOOdy
-----Ursprüngliche Nachricht----- Von: ProFox profox-bounces@leafe.com Im Auftrag von Joe Yoder Gesendet: Donnerstag, 27. Juni 2024 02:19 An: profoxtech@leafe.com Betreff: 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
Joe:
Tamar Granor has probably published more articles on Combo- and Dropdowns than anyone. Visit her website at http://www.tomorrowssolutionsllc.com/index.html and search for "Combo" on her articles or presentation pages. Happy Hacking!
P.S. Doug Hennig also: https://doughennig.com/papers.aspx "Drop" is the keyword to search
On Wed, Jun 26, 2024 at 8:19 PM Joe Yoder joe@wheypower.com wrote:
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]