PC Review


Reply
Thread Tools Rate Thread

how to change the default properties of textbox

 
 
newbies
Guest
Posts: n/a
 
      8th May 2009
I have several textbox which have a different background color and font
type/size as the default textbox. How do I change the default background and
font size so that I do not need to change each individual textbox property?
Can someone share with me the steps in achieving this? I'm using Visual
studio 2008 and new to c#
 
Reply With Quote
 
 
 
 
Reece
Guest
Posts: n/a
 
      8th May 2009

Here is a starter idea since no one else has answered yet:
http://www.velocityreviews.com/forum...d-textbox.html

See CSS Properties Window on this page:
http://www.devx.com/codemag/Article/38741/1763/page/4

StyleSheets and Themes are words to search for. If you have a good ASP.NET
book, then look those topics up.

Good luck.


"newbies" <(E-Mail Removed)> wrote in message
news:6A3066E7-5B09-453F-858B-(E-Mail Removed)...
>I have several textbox which have a different background color and font
> type/size as the default textbox. How do I change the default background
> and
> font size so that I do not need to change each individual textbox
> property?
> Can someone share with me the steps in achieving this? I'm using Visual
> studio 2008 and new to c#



 
Reply With Quote
 
Reece
Guest
Posts: n/a
 
      8th May 2009
Oops! I thought I was in the ASP.NET newsgroup when I posted that.


"Reece" <(E-Mail Removed)> wrote in message
news:uXOMl.10015$(E-Mail Removed)...
>
> Here is a starter idea since no one else has answered yet:
> http://www.velocityreviews.com/forum...d-textbox.html
>
> See CSS Properties Window on this page:
> http://www.devx.com/codemag/Article/38741/1763/page/4
>
> StyleSheets and Themes are words to search for. If you have a good
> ASP.NET book, then look those topics up.
>
> Good luck.
>
>
> "newbies" <(E-Mail Removed)> wrote in message
> news:6A3066E7-5B09-453F-858B-(E-Mail Removed)...
>>I have several textbox which have a different background color and font
>> type/size as the default textbox. How do I change the default background
>> and
>> font size so that I do not need to change each individual textbox
>> property?
>> Can someone share with me the steps in achieving this? I'm using Visual
>> studio 2008 and new to c#

>
>



 
Reply With Quote
 
newbies
Guest
Posts: n/a
 
      8th May 2009
yes it is for windows form application and I am not using wpf.
Anyone any suggestion/ideas?

"Reece" wrote:

> Oops! I thought I was in the ASP.NET newsgroup when I posted that.
>
>
> "Reece" <(E-Mail Removed)> wrote in message
> news:uXOMl.10015$(E-Mail Removed)...
> >
> > Here is a starter idea since no one else has answered yet:
> > http://www.velocityreviews.com/forum...d-textbox.html
> >
> > See CSS Properties Window on this page:
> > http://www.devx.com/codemag/Article/38741/1763/page/4
> >
> > StyleSheets and Themes are words to search for. If you have a good
> > ASP.NET book, then look those topics up.
> >
> > Good luck.
> >
> >
> > "newbies" <(E-Mail Removed)> wrote in message
> > news:6A3066E7-5B09-453F-858B-(E-Mail Removed)...
> >>I have several textbox which have a different background color and font
> >> type/size as the default textbox. How do I change the default background
> >> and
> >> font size so that I do not need to change each individual textbox
> >> property?
> >> Can someone share with me the steps in achieving this? I'm using Visual
> >> studio 2008 and new to c#

> >
> >

>
>
>

 
Reply With Quote
 
newbies
Guest
Posts: n/a
 
      8th May 2009
Hi Peter,
I've created a textbox class and compiled it. However when I drop the newly
created control from the toolbox to a form it still has the default textbox
font type and size instead of the customised font type. What could be
missing? The code for the class is below:

namespace stdformtemplate
{
public class ucTextbox : TextBox
{

private void InitializeComponent()
{
this.SuspendLayout();
//
// ucTextbox
//
this.Font = new System.Drawing.Font("Verdana", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.ResumeLayout(false);

}
}
}


"Peter Duniho" wrote:

> On Thu, 07 May 2009 22:46:01 -0700, newbies
> <(E-Mail Removed)> wrote:
>
> > yes it is for windows form application and I am not using wpf.
> > Anyone any suggestion/ideas?

>
> I can't think of any built-in way.
>
> One obvious possibility is for you to sub-class the TextBox class,
> providing your own default values in the sub-class, and then use that
> class instead of TextBox in your form instance.
>
> A really awful, difficult way would be to enumerate the TextBox instances
> in your form, setting the properties to your desired defaults once they
> have been created. The worst part about that would be that you'd have to
> do something, probably inspecting the InitializeComponent() method for the
> form using reflection, to figure out which instances had had their
> defaults overridden in the Designer (I suppose an alternative to that
> would be to require coders to maintain a list of objects and property
> names to skip...but that'd be really fragile).
>
> The only up-side I see to that approach is that you could add the code
> once, and it would work with any already-created Form classes. Providing
> a custom sub-class for TextBox would require at the very least a
> search-and-replace in all the *.Designer.cs files, to make "TextBox"
> instances the type you want instead (you'd have to change both the field
> declaration and the initialization, of course), and of course going
> forward people would have to remember to use the sub-class instead of the
> TextBox class.
>
> Now, all that said...there's some kind of support in Forms (and Windows
> generally) for "visual styles". I've barely noticed it, and don't have
> the specifics myself. But it's possible that via that, you can override
> the default behavior. I don't really know, but you might as well spend a
> few minutes looking into it, if it's important to you.
>
> Pete
>

 
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
How do you change the default paragraph setting for a textbox Old Man Microsoft Word New Users 1 19th May 2009 04:28 AM
How to change default language of a TextBox? =?Utf-8?B?QmlzaG95?= Microsoft Dot NET Framework Forms 1 13th Nov 2006 03:05 PM
Default in a textbox and change a module name =?Utf-8?B?ZmlsbzY2Ng==?= Microsoft Excel Programming 4 22nd Apr 2005 08:36 PM
Change the default setting in Insert/Textbox =?Utf-8?B?Z2l6ZWxh?= Microsoft Powerpoint 9 4th Jan 2005 01:06 AM
How to change the default tab spacing for textbox? Ben Microsoft C# .NET 0 18th Aug 2003 05:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:44 AM.