Hi,

Not sure if this is any help to anyone, but thought I'd put something back into the system for a change...

I've had to wrap the datalist control up in a usercontrol in order to get around some of its problems with data binding to my object library (another story all together!). One problem I've noticed with it is that the "move" method doesn't exactly do what it says on the tin.

I needed to resize the data list control so that it stays the same size as it's parent usercontrol object, so I used the following code to move it to (0,0) and resize it at the same time:

VB Code:
  1. Private Sub Usercontrol_Resize()
  2.  
  3.     on error resume next
  4.  
  5.     ' move and resize at the same time
  6.     lstData.Move 0, 0, UserControl.Width, UserControl.Height
  7.  
  8.    
  9. End Sub

This caused a strange bug. When the usercontrol is placed on the form, everything is resized allright, but when the list is populated, only the number of items that would be allowed if the list wasn't resized would be shown, even if there is space for more. Nasty one to track down. It's as if the actual list of items is remembering the size that the list was when it was put onto the usercontrol object.

I've managed to sort this by separating the move into 3 steps - moving to (0,0), and then resizing using the width and height properties. E.g.:

VB Code:
  1. Private Sub Usercontrol_Resize()
  2.  
  3.     lstData.Move 0, 0
  4.     lstData.Width = UserControl.Width
  5.     lstData.Height = UserControl.Height
  6.  
  7.    
  8. End Sub


This was done using VB6 Sp5, ADO 2.7 and Win 2000 sp2.

Hope this helps someone. Probably been posted before sometime, but I couldn't find it.

Trev.