Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIST BOX BEHAVIOUR 2

Status
Not open for further replies.

Ildegardo

Technical User
Feb 23, 2008
12
0
0
IT
Hi all,
I’m scrolling trough the different records of a file using a List Box linked to a field of this file.
The List Box has the following settings:
- style = 2
- rowsourcetype = 2
- rowsource = “TOOLS.tool_ID” (being TOOLS the alias of the file, tools_ID the name of the field which content I like to have shown in the List Box)

In the same form I also have some Text Boxes, supposed to show other fields of the same record selected in the List Box, allowing, as an example, the user to modify the field content.
These Text Boxes have settings
- controlsource = “TOOLS.XXXX” (where XXXX is the name of the field which content is supposed to be shown in that Text Box)

I have the following inconveniences:
- When firstly showing the List Box no content is appearing on it (I only get an empty blue bar). The user needs to drop the list to see some content. This happens also after having issued GO TOP for the file after it has been selected, and before giving the focus to the List Box.
- Text boxes on the contrary immediately get the content of the record selected when issuing GO TOP, but, while scrolling the List Box they do not change anymore consequently not showing the content of the record currently selected.

How can I solve above issues?
Thanks in advance for your help.
Ildegardo
 
From what you say you're using a combobox in dropdown list style, not a listbox.

The behaviour of your combobox is normal and you could have it show an inital record by setting a controlsource, but then the purpose for the combobox to select the record would be broken, as then the controlsource would determine which record should be selected.

So either you live with that or you try combobox1.listindex =1.

Regarding the refresh problem: Simply try THISFORM.REfresh() in the interactive change of your combobox.

Bye, Olaf.
 
Hi Ildegardo,

There are several issues here. First, as Olaf rightly says, you are obviously using a combo box, not a list box (if that wasn't so, your Style = 2 would fail, because listboxes don't have a Style property).

After you have populated the combo box, you should do the GO TOP, then set the combo's ListIndex to 1. That way, you'll see the first ID in the combo, plus you'll see the correct data in the textbox.

In the combo's InteractiveChange, issue THISFORM.Refresh. That will keep the textboxes in sync.

Is the table buffered? If so, if it is row buffered, you should disable the combo box (and any other navigation control) while the user is editing the textboxes. If you don't, the edits will be committed as soon as the user selects another combo box item, and before you have done any validation, which might not be what you want. If the table is table buffered, you need an explicit Save button, otherwise all the edits could be lost if the user quits the form without saving.

Finally, I'd question your use of a combo box in this context. Although a comnbo box should work perfectly well, a listbox would be easier for the user to work with, as it would let them click directly on an item without having to go through each one in turn. Not a major point, but worth keeping in mind.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Olaf and Mike,
First of all thank you for your (helpful) replay.

Sorry for my inappropriate identification of the control I’m using. It is really a Combo Box not a List Box
I will reconsider my decision of using Combo Box and consider the possibility to switch to a List Box

Regards
Ildegardo.
 
Hi Ildegardo!

In fact you'd normally use a grid and display a little more info about each record for record selection, instead of interactivechange() use AfterRowColumnChange(). With simpler tables you can even use it for data entry.

The combobox is okay and a listbox is also fine. Just don't set it up for multiselect. Both the listbox and Grid do take more space but give a better overview over all records.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top