Visual Studio .NET - treeview checkbox css - Asked By Alek Tolstoi on 13-Aug-08 08:47 AM

hi all,

i have an treeview user control. i need to add different style to a checkboxes that are selected and not selected, as well as, change the text to different style.

how can i do that? the tree gets populated on the server side and not bound to data source.

Can I use CSS and set each treenode to specific style??? can someone show me how this can be done?


reply - Binny ch replied to Alek Tolstoi on 13-Aug-08 02:15 PM


I think it not possible to set each treenode to specific style..

Well u find the solution please post it to me, if you can friend


treenodestyle - Partha Mandayam replied to Alek Tolstoi on 13-Aug-08 05:30 PM

You can manipulate the treenodestyle property. See this link.

Try this - ram kumar replied to Alek Tolstoi on 14-Aug-08 01:24 AM


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <link rel="stylesheet" href="SimpleTreeView.css" type="text/css" />
    <link runat="server" rel="stylesheet" href="~/CSS/Import.css" type="text/css" id="AdaptersInvariantImportCSS" />
<!--[if lt IE 7]>
    <link runat="server" rel="stylesheet" href="~/CSS/BrowserSpecific/IEMenu6.css" type="text/css" id="IEMenu6CSS" />
<!--[if gt IE 6]>
    <link runat="server" rel="stylesheet" href="~/CSS/BrowserSpecific/IEMenu7.css" type="text/css" id="IEMenu7CSS" />
    <form id="form1" runat="server">
        <asp:TreeView ID="EntertainmentTreeView" runat="server"
                <asp:TreeNode Text="Music" SelectAction="Expand">
                    <asp:TreeNode Text="Classical" />
                    <asp:TreeNode Text="Rock" SelectAction="Expand">
                        <asp:TreeNode Text="Electric" />
                        <asp:TreeNode Text="Acoustical" />
                    <asp:TreeNode Text="Jazz" />
                <asp:TreeNode Text="Movies" SelectAction="Expand">
                    <asp:TreeNode Text="Action" />
                    <asp:TreeNode Text="Drama" />
                    <asp:TreeNode Text="Musical" />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        <div id="EntertainmentMessage">
            <asp:Label id="MessageLabel" runat="server" />
    public void OnClick(Object sender, EventArgs e)

    public void OnCheckChanged(Object sender, TreeNodeEventArgs e)
    public void GiveFeedback()
        MessageLabel.Text = "";
        if (EntertainmentTreeView.SelectedNode != null)
            MessageLabel.Text += "You selected " + EntertainmentTreeView.SelectedNode.Text + ".";
        if (EntertainmentTreeView.CheckedNodes.Count > 0)
            MessageLabel.Text += "&lt;br /><br />The checked values are:<ul>";
            foreach (TreeNode item in EntertainmentTreeView.CheckedNodes)
                MessageLabel.Text += "&lt;li>";
                MessageLabel.Text += item.Text;
                MessageLabel.Text += "&lt;/li>";
            MessageLabel.Text += "&lt;/ul>";

    protected void Button1_Click(object sender, EventArgs e)

Link... - Atul Shinde replied to Alek Tolstoi on 14-Aug-08 03:16 AM
CSS friendly control adapter - Hemant Singh replied to ram kumar on 19-Aug-09 07:42 AM
Hi Ravi
wiil u Please send me a working code for this page as i am trying to implement this code but its not working
my id is:-
thanks & Regards