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 n开发者_如何学Goeed 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.
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.
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
精彩评论