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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

picture does not display 1

Status
Not open for further replies.

taterday

Programmer
Jan 28, 2009
183
US
I have an image in the first field of the list box. The following code below works perfectly with one exception.

If I click below the list items into a blank area in the listbox, nothing seems to fire that would trigger the code. I have put messageboxs into the click, refresh, gotfocus, when, requery, and the lostfocus event to see what firing.

The field for the picture remains blank until I click on a list item.

cprogram_images=area on the hard disk where the images are stored.
lcusercreated=default image if not found

LOCAL lcdiskname
STORE SPACE(1) TO lcdiskname

FOR iItem = 1 TO THIS.ListCount && files start at the 1th item
lcdiskname = THIS.List(iItem)
LCFILENAME = ALLTRIM(CPROGRAM_Images)+ALLTRIM(lcdiskname)+".bmp"
THIS.PICTURE(iItem)=IIF(FILE(LCFILENAME),LCFILENAME,LCUSERCREATED)
ENDFOR

I know there has to be way a fix this. I appreciate the help. Thank you in advance.
 
First of all, your observation is right: No events occur for the blank area of the listbox. This differs from the Grid. Even if the listbox is filled, when you scroll down the last item will scroll up to second last position and one line will remain blank. If you can't cope with that, then the listbox is not your control, this behaviour can't be changed.

>The field for the picture remains blank until I click on a list item.
In the first place I don't understand what you want to say with this. There is no field in a listbox, fields are parts of cursors or tables, there are columns in the listbox, and you only can add a picture to the first column of the listbox into the picture array. And also the picture column shows it's picture all the time, not just when you click on an item.

...after a while...

Testing, I see a partial reproduction. Leaving a listbox at default item height (font size), setting it's picture to fox.bmp, the fox doesn't appear besides items which scrolled into the visible area, unless you click on them. But this problem vanishes, if the fontsize is high enough, so only pictures exceeding the height of an item cause that problem. It's a clipping problem, as far as I judge it, if a pic needs to be clipped, that may lead to it not being drawn at all, unless you click into the item line.

So, I partially see your problems, but overall I don't see a fix for all your problems, the grid may be a better fit for your needs in this case.

Bye, Olaf.
 
I see the images all the time. I have the retrieval of the images in the refresh event of the page frame. I can click on one page to another page and the images are there. They are there prior to clicking in the blank space. Then they disappear. It like something is removing them. Are you saying it is what it is? Nothing I can do?

 
The pics disappear, when you click on the blank line?
You keep talking about a blank space, while there at most is a blank line in the listbox. Is it different to you? Could you post a screenshot to make us see what you see?
In what event do you have your code? If you want it to add pictures at start, put it in the INIT.

I told you, what you can do is instead use a grid. It has much more to offer than a listbox and may solve that flaw you see, however this is still not clear to me. You're confusing me by first saying "The field for the picture remains blank until I click on a list item." and now are saying "I see the images all the time...They are there prior to clicking in the blank space. Then they disappear." You're simply contradicting yourself. Now what is your problem? Pictures not appearing until you click an item or pictures disappearing? Or are this two problems?

The only way I see the pictures just appear when you click an item is, when the picture is too large. So you might try a smaller picture.

The picture array of listbox is just there so you can display a small icon to each item, about the size of a letter, not to display large pictures. What are you aiming for, at all?

Bye, Olaf.


 
The data is restricted to 9 records per listbox. The listbox is designed to display these 9 lines only. The listbox does not display a scroll bar unless the data exceeds 9 records, which it can not do.

The retrieval of the images is in the refresh event, I coded a refresh when an action occurs to the data.

Example of 5 data lines and a click on the blank space available for the 6th, 7th, 8th, or 9th record: each image that was displayed for each of the 5 data lines disappears.

Switching to a grid is not something my agency will support. If this can not be corrected using the listbox, management will have to accept.

 
I can't reproduce that problem.

If I add 5 records with a picture each and no further items, exactly nothing happens, when I click on the blank space, if I add 4 further records I can select them, but the pics of the other 5 items does not disappear.

What is bound to the listbox? A table, cursor, fieldlist? You should perhaps use AddItem() instead.

Bye, Olaf.
 
cursor rowsourcetype= 3

SQL command with a select on the data records into a cursor for their viewing a particular data type.

The data already exist in a table that is extracted through a request data entry screen from multi tables.

I have not used the additem().

Thank you for hanging in. I am happy to learn that you are not experiencing this problem. That seems to mean it is something I am doing with my listbox.

 
Well, I was using Additem, as using a cursor rowsource + picture array does not really match. I can see tomorrow, if using an alias rowsource changes the behaviour.

It wouldn't be much to do to change to AddItem, though. Instead of using the rowsourcetype 3 do the query INTO CUSOR then SCAN..ENDSCAN and add the up to 9 items in that loop.

Bye, Olaf.
 
I don't understand "the query INTO CUSOR then SCAN..ENDSCAN"

My rowsource is the select f1, f2,f3, f8 into cursor clist1 where f1= 'AC' order by f3

Where does the Scan Endscan go?

thanks
 
>Where does the Scan Endscan go?
Into the Init for example. Anywhere you want and need.

Instead of using a rowsourcetype 3 you don't use a rowsource at all. You use Listbox.AddItem() to add the items in a loop goinbg through all records, you may no DO WHILE NOT EOF("clist1") ... SKIP 1 ENDDO, but it's much simpler with SCAN..ENDSCAN. You can also do it in the form init or wherever you think it's needed, eg in page activate. Wherever and whenever it's needed.

So the code to fill your listbox would be
select f1, f2,f3, f8 from sometable into cursor clist1 where f1= 'AC' order by f3
Scan
Thisform.listbox1.additem(clist1.f2)
EndScan

And then you can also set the picture for that item in that loop, while you're at it.

The advantage is, you don't get the pics appearing or disappearing. A disadvantage is, if you change data you need more than a listobx.requery, you need to requery yourself, calling the method with the code to fill the listbox once more. Before you add the items again, you just need Thisform.listbox1.clear()

It's more work, but you get rid of the picture behaviour.

Bye, Olaf.
 
I will try the above.

Thank you.

I am giving you a star for your dedicated help. I appreciate your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top