Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8509963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:34:37+00:00 2026-06-11T03:34:37+00:00

I am writting a code to disable selcted items in LISTBOX. i.e I want

  • 0

I am writting a code to disable selcted items in LISTBOX.
i.e I want to show item in list but don’t want user to select it.
As shown in image below. Or similar image in link.
Is it possible in VB6 ?
Please help.

list box

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:34:39+00:00Added an answer on June 11, 2026 at 3:34 am

    You can’t do this with a ListBox without serious owner-draw fun. However, you could do it with a list view control.

    The closest I have done to this is to change the forecolor of disabled list items, and intercepted item click events so that the item is unselected. The Tag property of the list item is used to store the “disabled” state.

    I ought to mention that I couldn’t get this code to prevent the item from being “selected” whilst the mouse button is done. To do this, you would have to do some subclassing.

    The following class “ListViewWrapper” should be added to the project:

    Option Explicit
    
    Private Const m_ksDisabled                  As String = "D"
    
    Private WithEvents m_oListView              As ListView
    
    Public Sub Initialise(ByRef the_oListView As ListView)
    
        Set m_oListView = the_oListView
    
    End Sub
    
    Public Property Let ListItemEnabled(ByVal the_oListItem As ListItem, ByVal the_bEnabled As Boolean)
    
        If Not the_oListItem Is Nothing Then
            If the_bEnabled Then
                the_oListItem.Tag = Empty
                the_oListItem.ForeColor = vbWindowText
            Else
                the_oListItem.Tag = m_ksDisabled
                the_oListItem.ForeColor = vbGrayText
            End If
        End If
    
    End Property
    
    Public Property Get ListItemEnabled(ByVal the_oListItem As ListItem) As Boolean
    
        If Not the_oListItem Is Nothing Then
            ListItemEnabled = (the_oListItem.Tag <> m_ksDisabled)
        End If
    
    End Property
    
    Private Sub m_oListView_ItemClick(ByVal Item As MSComctlLib.ListItem)
    
        If Item.Tag = m_ksDisabled Then
            Set m_oListView.SelectedItem = Nothing
        End If
    
    End Sub
    

    It should be used like this:

    Private m_oListViewWrapper              As ListViewWrapper
    
    Private Sub Form_Load()
    
        Set m_oListViewWrapper = New ListViewWrapper
        m_oListViewWrapper.Initialise ListView
    
    End Sub
    
    Private Sub Command_Click()
    
        With m_oListViewWrapper
            .ListItemEnabled(ListView.SelectedItem) = Not .ListItemEnabled(ListView.SelectedItem)
        End With
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn and writting this part of code. while testing few
I am writing code to clone object but have no cue from Hobo documentation.
When writing Scala code in Emacs, I notice the following indentation issue: List(1,2,3).foreach{ x
Is there a way to to disable intellisense in ax2012's code editor? sometimes when
I am writing PHP code where I want to pass the session id myself
When writing code, I often place debug messages in the code. The debug messages
While writing code in a file that would comprise of PHP, HTML, CSS &
While writing code, it is pretty common to request a page with an appended
When writing code in an Eclipse project, I'm usually quite messy and undisciplined in
I'm writing code to import dozens of moderate sized text files into SQL SERVER

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.