CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 1999
    Posts
    128

    Interesting problem (kind of)...

    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?

    -------------------------
    Nick A.

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Interesting problem (kind of)...

    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.


  3. #3
    Join Date
    Dec 1999
    Posts
    128

    Re: Interesting problem (kind of)...

    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...

    -------------------------
    Nick A.

  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Interesting problem (kind of)...

    >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.


  5. #5
    Join Date
    Dec 1999
    Posts
    128

    Re: Interesting problem (kind of)...

    Well then, maybe it's the right time to stop using it...

    Thanks for the tips.

    -------------------------
    Nick A.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured