views:

275

answers:

2

I have a asp.net treeview control that I need to be able to set a parent node to partially checked to show that child nodes are checked. Basically I need a 3 state or multi-state checkbox. All I can see from looking through the code is ways to set checked true or false.

Thanks.

+2  A: 

There is no 3-state or multi-state checkbox in the .Net framework, mostly because this functionality isn't supported in HTML for a checkbox. There are a number of third party components which do this (such as "FolderView" controls). Or you could pretty easily roll your own server control for this. Sorry for the bad news.

Tim C
Sounds like I'm buying one. Stupid check box. Unfortunately I don't have time or the risk tolerance to roll my own.
dilbert789
+2  A: 

I've done this before. What you essentially do is keep track of the state of the underlying checkbox. Utilizing a custom javascript class and CSS sprites for your images, you overlay the checkbox with the appropriate image.

Here is a quick example I found

http://www.codeproject.com/KB/aspnet/TriStateCheckBox.aspx

Here is the concept of CSS Sprites and the tri-state checkbox. I've done something along these lines.

http://shamsmi.blogspot.com/2008/12/tri-state-checkbox-using-javascript.html

Danny G