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!

Duplicate display of records in list box

Status
Not open for further replies.

sdocker

IS-IT--Management
Aug 12, 2010
218
GB
I am using a 2 column list box. When I use the scrollbars to go to the top, a line is sometimes displayed twice. It is usually one of the top few lines. The Controls value is correct. It is just dispalying the wrong data.

For example:
one
two
three
four
.
.
.

shows up as:
one
one
two
three
.
.

If I click on the second "one", the display changes to "two", (which is correct), but it now shows:
one
two
two
three
.
.

The arrow, home and end keys work fine.

I remember seeing something about this, but could not locate it. Arefresh does not seem to affect the selected item, but I can't figure out how to refresh the list box if the scrollbars are moved.

Thanks,
Sam
 
Sam, what version of VFP are you using? I think the behaviour you are seeing was caused by a bug in an old version which has since been fixed. If you could clarify that, I will try to find more information.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hm, never saw this one.

You might try to change listbox height by 1 or 2 pixels and see, if that behaviour stops.

This might be an effect of an almost fit of a further line of items. With grids you get a somewhat similar effect if the last pixel line is not a grid line, clicking into the last line scrolls the grid. It's not identical, just similar in that the size of the control area influences it's behaviour, if that would work.

Another thing you can try is to listbox.REQUERY() to let it redraw it's items. You might do so in the OnMouveItem() event to react to scrolls, but I am not sure if that event happens then.

Try these out separate from each other, start with changing the size, if that does not work out try REQUERY(), first try that only in When() event or GotFocus(), an event only occuring once for each focussing of the control, finally in OnMouveItem(). Requerying the listbox might also have a negative effect of scrolling back to the active record. Just try a few things.

Bye, Olaf.

 
Mike,

I am using VFP 9.0 SP2, Versaion - 09.00.0000.7423

Olaf,
Changing the height, had no effect. I also turned "Integral Height" off. No difference.
The When or GotFocus event don't help because these events don't fire after the scroll bars are moved.
The OnMoveItem only occurs if an item is moved by the Mose, Keyboard or Prgramatically.

I tried putting a Refresh in the MouseUp event. It does the job, but I have to click the mouse twice to select an item. After the first click the selected item highlights for a flash and then the highlight reverts to the previous selection.

BTW; The RowSource is Fields from a Table.

Sam
 
You could try and turn off (or on - depending on it's current state) graphics hardware acceleration in display options. That solved other visual problems I had.

If a refresh in mouseup helps to refresh the list, it's a sign the click on an item makes the list scroll internally, not just visually. I tried to reproduce the effect, but couldn't get it working.
Can you post dimensions top/left/height/width off the listbox and the font face and size and other settings used? Maybe that'll help reproduce the problem. And maybe you could try another font or font size.

Bye, Olaf.
 
Olaf,

I put This.refresh in the MouseMove method, and it seems to help. When I scroll up the duplicate display is there but refreshes as soon as I release the mouse button. If I scroll off the control without releasing the mouse button, it refreshes when move over the control. Not a perfect situation, but somewhat workable.

FYI:
The control is a ListBox . These are the non-default properties:
BoundColumn = 1
ColumnCount = 2
ColumnWidths = 130,250
FontSize = 9
Height = 164
Integral Height = .T.
ItemBackColor = 64,128,128
ItemForeColor = 255.255,255
Left = 50
MouseMove = THIS.REFRESH
Name = lstClients
RowSource = CLDATA.Code,Name
RowSourceType = 6 - Fields
Top = 62

I hope this helps and you can reproduse it.

Thanbks alot,
Sam
 
I setup a listbox that way, no reproduction of the problem.

If these are all non default properties the width of the listbox will be to narrow to show the two columns. So what about the parent class? Is it a native listbox or is there something inherited? That could easily explain your problem is rooted in parent class code.

What about the field types and lengths of the cldata table?

Bye, Olaf.
 
So Sorry Olaf, I left off the width. It is 396

It is a native listbox.
The field type are both Character. The widths are: Code = 10, Name = 50
There are 42 records in the table.
When the control gets focus, scroll to the bottom and then back up. This is when I can the problem.

Sam
 
Still no reproduction.

What item should create the effect, when selected after scrolling back? top item? bottom item? some item in the middle?

Bye, Olaf.
 
It happens when I scroll all the way down then all the way back up. It is usually one of the first few items in the list. It doesn't matter if an item is selected or not.

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top