ComboBox Drop Failed. RRS feed

  • Question

  • Dear All,

    I'm using a ComboBox in Container, I want to use Escape for three actions. First for Close ComboBox List Portion if it is open, Second for Close/Invisible Container, Last for Quit from Form.

    Second and Third action is working properly but when I use Escape for first action (if List Portion of ComboBox is open), it dosn't close/drop the List Portion and shows as Disabled.

    I used Tom's following code but not succeeded.
    Identify combo dropdown list is closed

    I just want to close list along with ComboBox after pressing Escape, Any clues please share ...

    ShahidSQL (India)

    Saturday, June 15, 2019 8:19 AM

All replies

  • Can you show how you configured your combobox and what code is inside it (dorectly and in the class used, if it's not a base class combobox)?

    Becuase a native combobox I just tried simply closes at ESC, doesn't have the dropdown list staying open. In regard to appearingg disabled: If I close a combobox via ESC the whole form reacts and becomes inactive, that renders the title bar greyed out, but nothing else. I don't know if that graying out would be applied to the dropdown list of a combobox, because I don't see it staying open.

    I think you worked around problems because of a misconfigured data binding and the real solution would be keeping it at its native behaviour and don't need more than valid/interactivechange.

    If you want to be able to tell if a user actively made a pick of a list, the solution is to start on an empty item, an extra record you insert into the combobox recordsource cursor to start at and only if the controlsource target value later reflects somehting else than the blank value or ID 0 or NULL you take that as an input and in the QueryUnload of the form or whenever it is important to you the user has picked a non optional item, that's how you know that, not through control events.

    Your corce concern should be about the state of the record/buffer or whole workarea your form controls are meant to maintain, not about the controls themselves, they're just the slave UI. So make it so the record may start off in an invalid buffered state you then can reject and ask the user to either complete with the mandatory details or escape by cancelling and reverting all the changes., aka not saving.

    If you have any anormal behaviour like this, I believe you, I have seen very unusual things, but it has to be an unfortunate setting or handling suppressing or enforcing of events with object or class code or unusual combinations of rowsourcetype and rowsource or whatever. 

    One of the unusual and almost anachronistic thnigs you can set a combobox to is RowSourceType Alias. It almost acts as Fields and the solution to get more controlled behaviour is to use Fields. You should never just specify the workarea alias as RowSource, please let the combobox know what exact fields you want in the columncount columns of the combobox. And if you keep that at 1 specify that one field with aliasname.fieldname. That works best and is extended to further fields with columncount>1 and correspondingly many field specified as aliasname,field1, field2, field3,... So you specify aliasname for the first field only with dot, then fieldname, just like addressing a field in code, and then comma separated further field names, just field names, no repeat of alias name, no dots anymore.

    I don't know what you're doing, but using Alias as rowsourcetpye and just the alias name is wrong in the same way it is wrong to use for the grid to automatically display as many columns as the workarea has. The dropdown by defaulöt only shows the frst column, which is the first problem, but also in the grid you don't get what you want and have all that unwanted behaviour if you go such a lazy route. You spoecify what you exactly want in each column, that helps.

    Bye, Olaf.

    Sunday, June 16, 2019 7:04 AM
  • In ComboBox->GotFocus
    This.RowSource="SELECT NAME FROM <Talble> INTO CURSOR csrName NOWAIT"
    IF EMPTY(This.DisplayValue)=.T.

    In ComboBox->LostFocus
    Sunday, June 16, 2019 11:10 AM
  • All the bad experience you have come from using a query.
    Why? If there is no changing condition you add your rowsource once it init. In this case I'd do this just once in Combo Init:

    This.RowsourceType = 6
    This.Rowsource = "crsName.Name"

    A static list doesn't need any cointrol.requery, too. You may also just USE <TABLE> IN 0 AGAIN Alias cvoCursor.

    If you want an empty item additional to the list the table has, and preselect it do this:

    INSERT INTO crsName VALUES ("")
    This.RowsourceType = 6
    This.Rowsource = "crsName.Name"

    Now if you want to set the value to nothing at gotfocus you can do that. Not via Listindex, that's the method if you're using Additem and not a cursor. You select the record.

    You get easier control via a Controlsource and using a list with ID, even if you only want to use the combobox to finally get a picked value and not directly let that go into another tabless field, you can use an object and one of its properties as controlsource.

    PS: And even if your table changes,

    a) the USE of it once in init means the combo stay up to dayte, especially if you do the combo.requery in gotfocus. Maybe not with every gotfocus.

    Understand the combo.requery is NOT about redoing the SQL query if the rowsourcetyp ei s aquery, it is about rebuilding the combobx items from the rowsoure, whatever type it is, becuase internally it's always using the listitms, a cursor as rowsource is read into that without you needing to write a scan-loop and additems. Plus cursor related rowsrouce tpyes means in valid and interactivechange you can be sure the picked item also becomes the acitve record in the workarea, that is the nice thing about this way of binding data to the combo. You get a lot of things done without code.

    b) if your query is more complex than the samole code given, still do it in the GotFocus event, not in the rossourcetype. Just use the cursorname and fieldnames in the combobox. You thereby redo what the rowsourcetype query promises to do for you, for the advantage, the compiler actially checks your query, whereas in a rowsourcetype its just a string to the comipler and only executiuon will tell, whether it works. You also can't make use of parameters as the query diesn't run in the scope of any code. So in this case doing the code has advantages, and you write the query anyway.

    Bye, Olaf.

    Sunday, June 16, 2019 12:31 PM
  • Thanks Olaf,

    I used the method as you mentioned above but the problem is still remains.
    I think problem is between the ComboBox-LostFocus event and Container-Visible=.F. action.
    I used KEYBOARD '{ALT+UPARROW}' also on Escape keyboard event but not working.
    Most probably Container is being closed before ComboBox is being Droped, That's why the list portion is remains open.

    Well experiments are still continued ... :)

    If you have any more suggestion you please advice me ...

    ShahidSQL (India)

    Sunday, June 16, 2019 4:40 PM
  • Hi,

    Do you resolve the issue?

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, June 26, 2019 5:39 AM