Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

Hiding the selection in a CheckedListBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jared - 04 Feb 2007 04:31 GMT
Is it possible to do away with the "selected" appearance of an item in
a CheckedListBox (v1.1)?  When I click an item, its background turns
blue and its text turns white.  I want the checkbox to toggle (which
it currently does), but I don't want the list item to appear
"selected".

TIA
Jared
ClayB - 05 Feb 2007 10:49 GMT
You can try handling SelectedIndexChanged event and clearing the
selection there. This got rid of the selection after the click for me,
but there still was a temporary selection that flashed as you click
the checkbox. This code just removes it immediately.

private void checkedListBox1_SelectedIndexChanged(object sender,
EventArgs e)
{
    int index = checkedListBox1.SelectedIndex;
    if(index > -1)
    {
        checkedListBox1.SetSelected(index, false);
        checkedListBox1.SetItemChecked(index, !
checkedListBox1.CheckedIndices.Contains(index));
    }
}

================
Clay Burch
Syncfusion, Inc.
Jared - 06 Feb 2007 22:52 GMT
> You can try handling SelectedIndexChanged event and clearing the
> selection there. This got rid of the selection after the click for me,
[quoted text clipped - 17 lines]
> Clay Burch
> Syncfusion, Inc.

Thanks Clay, that works pretty well.  I had to eliminate
SetItemChecked() or the checkbox would never change state.  Looks like
SetSelected() was exactly what I needed.

Cheers!
Jared

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.