Results 1 to 4 of 4

Thread: Un-highlist listbox when not enabled?

  1. #1

    Thread Starter
    Lively Member Mugsy323's Avatar
    Join Date
    Oct 2014
    Posts
    112

    Question Un-highlist listbox when not enabled?

    I created a form with a listbox. It always loads with the default text selected.

    The problem is, I disabled the listbox until the user completes a previous step, yet the selection highlight remains (with unseen text.) I don't want a highlight until after the user selects an item.

    Is there a way to hide the selection until the object is enabled and a selection is made? TIA

    What I'm getting:
    Name:  example0.jpg
Views: 244
Size:  3.6 KB


    What I want:
    Name:  example1.jpg
Views: 282
Size:  4.4 KB


    Code:
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ListBox1.SelectedIndex = 0 ' This value will change in finished code.
        End Sub
    End Class
    (ListBox1 contains 4 items and is Disabled by default. Changing it to Enabled by default shows the text but I don't want the listbox enabled or the selection visible until the previous step is completed.)

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Un-highlist listbox when not enabled?

    Code:
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Label1.Select
            ListBox1.SelectedIndex = -1 ' No item selected
        End Sub
    End Class

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Un-highlist listbox when not enabled?

    You can set SelectedIndex to 0. It’s setting the ActiveControl to a Label that should solve your problem…

  4. #4

    Thread Starter
    Lively Member Mugsy323's Avatar
    Join Date
    Oct 2014
    Posts
    112

    Re: Un-highlist listbox when not enabled?

    My apologies for not replying. Your reply got caught in spam filter.

Tags for this Thread

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