views:

103

answers:

1

Is there a way to highlight an item in a VB.Net listbox without allowing the user to change selection?

When I set the selection Mode to "NONE" I can´t select an item in the code. Same when I disable the listbox.

+1  A: 

Setting the list box' Enabled property to False works fine:

Public Class Form1
  Public Sub New()
    InitializeComponent()
    ListBox1.Items.AddRange(New String() {"one", "two", "three"})
    ListBox1.Enabled = False
  End Sub

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ListBox1.SelectedIndex = 1
  End Sub
End Class
Hans Passant
Hmm... that was my first solution... and it didn´t work...I´m sure... now it works... GREMLINS!Sorry.
Doc Snuggles