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 / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

TreeView node style - for an individual node

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Homer J. Simpson - 23 Jul 2007 21:16 GMT
Hi all,

I just went over a *lot* of tree node style properties (LeftNodeStyle,
NodeStyle, ParentNodeStyle, RootNodeStyle, LevelStyles, HoverNodeStyle,
SelectedNodeStyle, etc etc etc) but can't find exactly what I want.

It seems that I'm in a situation where none of these predefined groups fit
the bill.  Ultimately, the style to use needs to be decided as I'm
dynamically adding individual nodes through code.  I'd like to do this:

if( [some convoluted conditions] ) {
   tnNewNode = new TreeNode( strCaption );
   tnNewNode.[Something] = "bold";
   tnParent.ChildNodes.Add( tnNewNode );
}

It's this [Something] property that I'm looking for--one that applies to an
individual node, but not necessarily others that happen to fall in some
common category.

I've managed to add separate styles for clickable nodes by using something
like:

.MyTreeClass a
{
   (styles that apply to all clickable nodes, which all happen to have an
archor tag)
}

...but I need finer granularity.  Thinking along the same way, I've hacked
together the following:

tnNewNode = new TreeNode( "<div class='clsTest'>" + strCaption + "</div>" );

and in my .css file:

.MyTreeClass .clsTest
{
   font-weight: bold;
}

But this is *so* ugly I can't help but think there's just gotta be some
better way to do this than force my own div around the node's text.
Brandon Gano - 23 Jul 2007 23:58 GMT
I think the CssClass property is the [Something] you are looking for.

--code--
if (...) {
   tnNewNode = new TreeNode(strCaption);
   tnNewNode.CssClass = "BoldNode";
   tnParent.ChildNodes.Add(tnNewNode);
}

--css--
.MyTreeClass .BoldNode {
   font-weight:bold;
}

> Hi all,
>
[quoted text clipped - 40 lines]
> But this is *so* ugly I can't help but think there's just gotta be some
> better way to do this than force my own div around the node's text.
Homer J. Simpson - 24 Jul 2007 14:03 GMT
>I think the CssClass property is the [Something] you are looking for.
>
[quoted text clipped - 9 lines]
>    font-weight:bold;
> }

I'm gonna have to try it regardless of that IntelliSense is telling me.  It
definitely did *not* popup the .CssClass property (that's the first thing I
was looking for).

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.