Click to See Complete Forum and Search --> : Interesting problem (kind of)...


Nick A.
February 17th, 2000, 08:14 AM
I have tried the following code:

private withevents lstDVList as ListBox

set lstDVList = Controls.Add("VB.ListBox", "lstDVList")
lstDVList.Top = 300
lstDVList.Left = 300
lstDVList.Width = 4000
lstDVList.Height = 4000
lstDVList.ZOrder
lstDVList.Visible = true



It works fine. It adds a listbox in my form dynamically.

Now, if i try to put the following line (before or after the SET, makes no difference :) )
lstDVList.Sorted = true


VB does not let me. It says "cannot assign to read-only property", which is logical because you are allowed to set this property only in design time.

If i may ask, how am i supposed to set this property? Anyone has any ideas?

Lothar Haensler
February 17th, 2000, 08:27 AM
you could try to use the Listview instead of a listbox.
It is more flexible as far as sorting is concerned.
You can achieve the same visible results, by using the Report mode.

Nick A.
February 17th, 2000, 08:43 AM
It IS a way to help me bypass this problem - and thank you for that - but it's not a solution to the problem. :) I wonder if they (MS) have ever thought of this...

Lothar Haensler
February 17th, 2000, 08:46 AM
>I wonder if they (MS) have ever thought of this...

in my opinion the listbox control is simply "old".
Even if you use a listbox "the API way", you have to set the LBS_SORT style bit upon creation of the listbox window and cannot change that after the window has been created, AFAIK.

Nick A.
February 17th, 2000, 09:03 AM
Well then, maybe it's the right time to stop using it...

Thanks for the tips.