Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Owner -Drawn Controls - Complete n00b

Status
Not open for further replies.

sugarflux

Technical User
Aug 14, 2003
111
GB
Hi all

Hoping someone can help me - I'm totally new to c# so need it spelt out really clearly if possible please!

I want to change the look of various controls, for example, radio buttons. I've experimented with putting a background image within the associated label but have read about Owner-drawn controls and the paint command.

I'm thinking this could potentially help me out.

Please can someone guide me through how i could, for example, simply change the colour of a radio button?

Thanks

~S~
 
have you looked into using WPF for the user interface. You have a lot more control over the style.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Unfortunately this is part of a massive (million-pound +) system which has been built in silverlight and .Net.

I am working on just one part of it which is "styling".

At the moment I am using a comination of CSS and Javascript to hide the default controls (such as radio buttons and checkboxes) and give their associated labels a background-image.

The difficulty I am having is that obviously two images are required (checked and un-checked) and whenever a postback occurs all the controls default to un-checked even if the hidden control itself is checked.

I could use javascript on page load to loop through everything on the page and check the control state but would rather not have to do this as it may end up being pretty slow (esp. if the app ends up running on an iPad etc. which it might).

I am sure that there must be a way of achieving a different style of radio button (even if i can just ensure the ring is one colour and the dot in the centre is another cross-browser) using .Net?

Any ideas welcome!

Thanks

~S~
 
ok, this is completely different. I thought you were talking about a desktop/thick client app. silverlight uses WPF as the presentation framework (pretty sure about that anway). if your silverlight app is deployed as a webpage then you have javascript and css to aid with styling as well. I would recommend incorporating jquery.ui as well to help stylize the UI. this will make it much easier.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Hi Jason

Thanks for getting back to me. Yes i am utilizing jQuery. However the problem i have is that CSS and javascript do not have the ability to "style" web controls (such as radios and checkboxes).

For example, i cant change the colour of the ring on a radio button or the dot in the middle.

The only way to "style" the controls is to hide them and use background images within the labels. This is not ideal. I believe there may be a way of properly styling the controls utilizing .net (perhaps c#)....

...But I can't work out where to start!

~S~
 
what do you mean by "web controls"? html elements? then yes that is what css/js does. if you mean server controls, then no server controls are just that server, css and js run on the client against the DOM.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Hi Jason

Yes - HTML elements. But rather than DIVs and SPANs I'm talking about INPUT elements, such as radio buttons and checkboxes.

CSS and Javascript cannot effectively "style" these across browsers as the controls are stored within the browsers themselves.

For example, there is no way to change the colour of the ring or the dot that comprises a radio button....

~S~
 
no, that you can't do. but you can apply styling to radio buttons for selected/unselected. the jqueryui button makes this very simple

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top