Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other C# .NET Posts   Ask New Question  Ask New Question With Power Editor

textbox property
madhu radha posted at Saturday, November 07, 2009 6:51 AM

hi all,

  i want a textbox for cost purpose which should accept  dot before last two digits  

Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0
re
Web star provided a rated reply to madhu radha on Saturday, November 07, 2009 8:47 AM

u can use this

Listing 1 - Overriding the KeyPress event

        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar >= '0' && e.KeyChar <= '9')
            {
               
// move all digits over to the left
                Shift(); 
                // make sure there is a prompt to replace
                int index = this.Text.LastIndexOf(PromptChar);
                if (index >= 0)
                {
                   
// insert the character typed into the last prompt character of the Text string
                    this.Text = this.Text.Substring(0, index) + e.KeyChar + this.Text.Substring(index);
                }
           }
            base.OnKeyPress(e);
        }

http://www.dotnetheaven.com/Uploadfile/mgold/MaskedCurrencyTextBox02252006005553AM/MaskedCurrencyTextBox.aspx

http://www.c-sharpcorner.com/UploadFile/jibinpan/MaskedTextBoxControl11302005051817AM/MaskedTextBoxControl.aspx

Reply    Reply Using Power Editor
  Rank Winnings Points
November 5 $55.00 143
October 10 $28.00 94

Use MaskedTextBox
mv ark provided a rated reply to madhu radha on Saturday, November 07, 2009 8:57 AM

Use the MaskedTextBox Control - http://msdn.microsoft.com/en-us/library/ka7h9fze.aspx
Reply    Reply Using Power Editor
M.V. 'Anil' Radhakrishna is a seasoned developer and a Microsoft MVP (ASP/ASP.NET). He blogs his little discoveries and Web development tips, tricks and trivia quite regularly. You can find some of his unusual code samples & snippets at his Code Gallery.
  Rank Winnings Points
November 6 $46.00 119
October 4 $66.00 225

re
Web star replied to madhu radha on Saturday, November 07, 2009 9:56 AM

if u are using latest version of vs.net 3.0 then there are one mask property of textbox , where u can set for input format as

MaskedTextBox.Mask = "####.##"

source is here http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask.aspx

Reply    Reply Using Power Editor
  Rank Winnings Points
November 5 $55.00 143
October 10 $28.00 94

RegularExpressionValidator
F Cali provided a rated reply to madhu radha on Saturday, November 07, 2009 11:43 PM

You can use the RegularExpressionValidator for your TextBox.  Here's a link to know more about the Regular Expression Validator:

http://msdn.microsoft.com/en-us/library/ms998267.aspx

From that link, you can use this as your validator: ^\d+(\.\d\d)?$

Regards,
SQL Server Helper

Reply    Reply Using Power Editor
How well do you know SQL? Find out with the free test assessment from SQL Server Helper:
http://www.sql-server-helper.com/free-test/default.aspx
  Rank Winnings Points
November 3 $65.00 168
October 0 $0.00 0