473,785 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copying styles from one control to another

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 SelectedNodeSty le 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.Sele ctedNode != null)
{
this.Tree.Selec tedNode.Selecte d = false;
this.FormTitle. Select(this.Tre e.SelectedNodeS tyle);
}
}
//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.Back Color = style.BackColor ;
linkButton.Fore Color = style.ForeColor ;
}
///END OF CODE

I'd like it such that if anyone comes along and specifies additional
properties to the SelectedNodeSty le, 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

Aug 22 '08 #1
2 1168
themes ?
"Josh Valino" <no spam pleasewrote in message
news:Ok******** ******@TK2MSFTN GP02.phx.gbl...
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 SelectedNodeSty le 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.Sele ctedNode != null)
{
this.Tree.Selec tedNode.Selecte d = false;
this.FormTitle. Select(this.Tre e.SelectedNodeS tyle);
}
}
//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.Back Color = style.BackColor ;
linkButton.Fore Color = style.ForeColor ;
}
///END OF CODE

I'd like it such that if anyone comes along and specifies additional
properties to the SelectedNodeSty le, 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

Aug 22 '08 #2
Dippity-do easy using a Skin after choosing to use either
[Theme|StyleShee tTheme] 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 pleasewrote in message
news:Ok******** ******@TK2MSFTN GP02.phx.gbl...
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 SelectedNodeSty le 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.Sele ctedNode != null)
{
this.Tree.Selec tedNode.Selecte d = false;
this.FormTitle. Select(this.Tre e.SelectedNodeS tyle);
}
}
//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.Back Color = style.BackColor ;
linkButton.Fore Color = style.ForeColor ;
}
///END OF CODE

I'd like it such that if anyone comes along and specifies additional
properties to the SelectedNodeSty le, 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
Aug 23 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1989
by: Quinton | last post by:
I'm running a website that uses CSS to format the text and a CGI program Coranto that icludes news updates via SSI. My problem is that some parts of the CSS don't seem to take effect on the included news. All four link styles are used, and all four work in the included text files. The text styles, on the other hand, seem not to work at all. The text that's part of the actual HTML file is formated according to the CSS codes. However, the...
2
1620
by: Praveen | last post by:
Hi, Is there a way to copy over a table's properties and styles (NOT it's child elements like tbody, trs, etc) into another table, besides doing them manually, one by one? Thanks Praveen
12
2577
by: dan.vendel | last post by:
Hi, I know nothing about javascript, but quite a lot about regulat html and CSS. Have bumped into a problem that people in this fine congregation perhaps can help me with. I'm making a webshop. When user eventually ends up at the credit card processor's secure pages, the styles are quite different from the actual site's. I have managed to change some basics through a control
3
1478
by: JezB | last post by:
What's the generally accepted approach for using Styles and Stylesheets in a web application based on .aspx files, Web Controls, User Controls, and code-behind modules (c# in my case)? Most style and stylesheet guides on the internet seem to be based on web sites (rather than applications) based on relatively static textual information. I have read that external stylesheet files are the way to go, but it seems to me that these only lend...
3
1788
by: Chris | last post by:
Hi I have another style sheet question: We effectively have a page that has two text boxes on it. We would like one text box to be in one style and the other text box to be in another style. The problem is we would like the user to be able to control the styles using style sheets. Is there anyway around this without hard coding the styles into the page?
5
1287
by: Bernie Yaeger | last post by:
When you use xp styles Application.EnableVisualStyles() Application.DoEvents() and you change a control's flat style to 'system', you then are not able to set the control's forecolor, or if you did set it, it reverts to the default
10
3860
by: jon | last post by:
I'm trying to use a hidden iframe to print the contents of one div seamlessly. Currently I can create the hidden iframe, copy the contents of the div to the iframe, and print it. I even have a method that initially copies all the original page's styles onto the new iframe to maintain look and feel. So far things work, and the div (along with look and feel from styles) are successfully copied to the iframe and printing just the hidden...
0
971
by: matt urbanowski | last post by:
Hi, I have a calendar control on a form in VS2003 and have applied some styles to it. I have separate styles for all of the groups e.g. DayHeaderStyle, DayStyle, NextPrevStyle etc. and one for the whole calendar. When I preview the calendar in Visual Studio, it looks fine. However, when I view the calendar in Internet Explorer, some of the styles don't appear how they should - for example, the next/previous month buttons come out black...
13
10727
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to process the file. The appearance of the command file triggers the device to grab the original file. My problem is I don't want to write the command file to the device until the original file from the workflow has been copied completely. Since these...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.