Click here to Skip to main content
15,891,513 members
Articles / Programming Languages / C#

Indian Number & Date Format

Rate me:
Please Sign up or sign in to vote.
3.17/5 (19 votes)
29 Aug 2012CDDL3 min read 115.1K   1.8K   41  
A control for Indian number format, converts number to words, Hindi words, comma style and Indian date processor

This article is a sponsored article. Articles such as these are intended to provide you with information on products and services that we consider useful and of value to developers

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace IndianFormatDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                try
                {
                    decimal val = decimal.Parse(textBox1.Text);
                    //int val = int.Parse(textBox1.Text);
                    label1.Text = Indian.IndianCurrency.CurFromat((long)val, true);

                    label2.Text = Indian.IndianCurrency.CurFromatWthDecimal(val, false);

                    label3.Text = Indian.IndianCurrency.toWords(val, "hi",false);

                    label4.Text = Indian.IndianCurrency.toWords(val, "en",false);

                    label5.Text = Indian.IndianCurrency.toWords(val, "hi", true);

                    label6.Text = Indian.IndianCurrency.toWords(val, "en", true);

                    label7.Text = Indian.IndianCurrency.toWords(val, "Marathi", true);

                    //label8.Text = Indian.IndianCurrency.toWords(val, "en", true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

        private void textBox2_Validated(object sender, EventArgs e)
        {
            dateTimePicker1.Value = DateTime.Parse(textBox2.Text);
        }

        private void textBox3_Validated(object sender, EventArgs e)
        {
            dateTimePicker2.Value = Indian.IndianDate.date(textBox3.Text);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //this.label1.Font = new System.Drawing.Font("Verdana", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            Indian.IndianCurrency.intFont();
            this.label1.Font = new System.Drawing.Font(Indian.IndianCurrency.rupeeFont.Families[0], 10.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Web Developer
India India
I am a computer engineer doing business at my city. I love to program is also engaged in part time programing. Normaly, work for fun and most of the time free of charge.

Comments and Discussions