PC Review


Reply
Thread Tools Rate Thread

Copying styles from one control to another

 
 
Josh Valino
Guest
Posts: n/a
 
      22nd Aug 2008
Hi,

I'd like to take the style properties from one control and apply them all to
the properties of another control, where they relate. The situation is
this:

I have a TreeView control, and the SelectedNodeStyle has some things set.
In addition to the TreeView, I have a few LinkButton controls. A user can
select a node in the tree or one of the LinkButton. I'd like the
LinkButtons to have the same look that a selected node has when it's
selected in the tree. Right now, I'm doing this:

///CODE
private void SomeLinkButton_Click(object sender, EventArgs e)
{
if (this.Tree.SelectedNode != null)
{
this.Tree.SelectedNode.Selected = false;
this.FormTitle.Select(this.Tree.SelectedNodeStyle);
}
}


//extension method in a static class
public static void Select(this LinkButton linkButton, Style style)
{
linkButton.Font.Bold = true;
linkButton.Font.Bold = style.Font.Bold;
linkButton.BackColor = style.BackColor;
linkButton.ForeColor = style.ForeColor;
}
///END OF CODE

I'd like it such that if anyone comes along and specifies additional
properties to the SelectedNodeStyle, he won't have to update the extension
method. Is there a more efficient way than what I currently have? I could
just manually add all the property mappings in my extension method, or I
could reflect all the properties out. I'm not excited by either solution,
so I'm curious if anyone has any other ideas. Oh, and tragically, just
mapping the same CssClass property won't work because of insane political
reasons that it hurts to think about.

Thanks



 
Reply With Quote
 
 
 
 
gerry
Guest
Posts: n/a
 
      22nd Aug 2008
themes ?


"Josh Valino" <no spam please> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'd like to take the style properties from one control and apply them all
> to the properties of another control, where they relate. The situation is
> this:
>
> I have a TreeView control, and the SelectedNodeStyle has some things set.
> In addition to the TreeView, I have a few LinkButton controls. A user can
> select a node in the tree or one of the LinkButton. I'd like the
> LinkButtons to have the same look that a selected node has when it's
> selected in the tree. Right now, I'm doing this:
>
> ///CODE
> private void SomeLinkButton_Click(object sender, EventArgs e)
> {
> if (this.Tree.SelectedNode != null)
> {
> this.Tree.SelectedNode.Selected = false;
> this.FormTitle.Select(this.Tree.SelectedNodeStyle);
> }
> }
>
>
> //extension method in a static class
> public static void Select(this LinkButton linkButton, Style style)
> {
> linkButton.Font.Bold = true;
> linkButton.Font.Bold = style.Font.Bold;
> linkButton.BackColor = style.BackColor;
> linkButton.ForeColor = style.ForeColor;
> }
> ///END OF CODE
>
> I'd like it such that if anyone comes along and specifies additional
> properties to the SelectedNodeStyle, he won't have to update the extension
> method. Is there a more efficient way than what I currently have? I
> could just manually add all the property mappings in my extension method,
> or I could reflect all the properties out. I'm not excited by either
> solution, so I'm curious if anyone has any other ideas. Oh, and
> tragically, just mapping the same CssClass property won't work because of
> insane political reasons that it hurts to think about.
>
> Thanks
>
>
>



 
Reply With Quote
 
HillBilly
Guest
Posts: n/a
 
      23rd Aug 2008
Dippity-do easy using a Skin after choosing to use either
[Theme|StyleSheetTheme] as we then go to PreInit, find the control and
change its SkinID property to whatever we want and the predeclared
properties in the skin are bound to the control.

We can do the same thing without using skins and themes in PreInit by
binding the CssClass property to a control.

"Josh Valino" <no spam please> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'd like to take the style properties from one control and apply them all
> to the properties of another control, where they relate. The situation is
> this:
>
> I have a TreeView control, and the SelectedNodeStyle has some things set.
> In addition to the TreeView, I have a few LinkButton controls. A user can
> select a node in the tree or one of the LinkButton. I'd like the
> LinkButtons to have the same look that a selected node has when it's
> selected in the tree. Right now, I'm doing this:
>
> ///CODE
> private void SomeLinkButton_Click(object sender, EventArgs e)
> {
> if (this.Tree.SelectedNode != null)
> {
> this.Tree.SelectedNode.Selected = false;
> this.FormTitle.Select(this.Tree.SelectedNodeStyle);
> }
> }
>
>
> //extension method in a static class
> public static void Select(this LinkButton linkButton, Style style)
> {
> linkButton.Font.Bold = true;
> linkButton.Font.Bold = style.Font.Bold;
> linkButton.BackColor = style.BackColor;
> linkButton.ForeColor = style.ForeColor;
> }
> ///END OF CODE
>
> I'd like it such that if anyone comes along and specifies additional
> properties to the SelectedNodeStyle, he won't have to update the extension
> method. Is there a more efficient way than what I currently have? I
> could just manually add all the property mappings in my extension method,
> or I could reflect all the properties out. I'm not excited by either
> solution, so I'm curious if anyone has any other ideas. Oh, and
> tragically, just mapping the same CssClass property won't work because of
> insane political reasons that it hurts to think about.
>
> Thanks
>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use Destination Styles/Copying Styles Dale Microsoft Word Document Management 3 8th Oct 2008 07:10 PM
Copying styles =?Utf-8?B?TWVs?= Microsoft Word Document Management 0 24th Oct 2007 11:58 PM
Copying Styles =?Utf-8?B?Um9zZW1hcnk=?= Microsoft Word Document Management 4 12th Oct 2007 08:38 PM
Copying Styles =?Utf-8?B?U2hhcm9u?= Microsoft Word Document Management 3 18th Aug 2006 06:05 AM
Re: copying styles Klaus Linke Microsoft Word Document Management 1 2nd Sep 2004 05:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:35 AM.