Click here to Skip to main content
15,895,798 members
Articles / Programming Languages / C#

WaterMark TextBox For Desktop Applications Using C#, .NET 3.5 and VS2008

Rate me:
Please Sign up or sign in to vote.
4.54/5 (35 votes)
22 Aug 2008CPOL3 min read 250.1K   9.8K   74  
Watermark TextBox for .NET
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WaterMarkDemo
{
    public partial class FrmWaterMarkDemo : Form
    {
        public FrmWaterMarkDemo()
        {
            InitializeComponent();
        }

        private void setWaterMarkButton_Click(object sender, EventArgs e)
        {
            waterMarkTextBox1.WaterMarkText = waterMarkTextBox.Text;
            waterMarkTextBox2.WaterMarkText = waterMarkTextBox.Text;
            waterMarkTextBox3.WaterMarkText = waterMarkTextBox.Text;
            waterMarkTextBox4.WaterMarkText = waterMarkTextBox.Text;
            waterMarkTextBox5.WaterMarkText = waterMarkTextBox.Text;
            waterMarkTextBox6.WaterMarkText = waterMarkTextBox.Text;
        }

        private void selectColorButton_Click(object sender, EventArgs e)
        {
            if (colorDialog.ShowDialog() == DialogResult.OK)
            {
                waterMarkTextBox1.WaterMarkColor = colorDialog.Color;
                waterMarkTextBox2.WaterMarkColor = colorDialog.Color;
                waterMarkTextBox3.WaterMarkColor = colorDialog.Color;
                colorPanel.BackColor = colorDialog.Color;
            }

        }

        private void selectFontButton_Click(object sender, EventArgs e)
        {
            if (fontDialog.ShowDialog() == DialogResult.OK)
            {
                waterMarkTextBox1.Font = fontDialog.Font;
                waterMarkTextBox2.Font = fontDialog.Font;
                waterMarkTextBox3.Font = fontDialog.Font;
                fontTextBox.Text = fontDialog.Font.Name;
            }
        }
    }
}

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 Code Project Open License (CPOL)


Written By
Architect Government
Qatar Qatar
Programmer since 1990 with Pascal, VC++, C#, ASP.NET, jQuery, J2EE and Android.
PMP Certified since 2009.
PSP Certified since 2005.
Business & System analyst since 2004.
Led teams in between 8 to 30 members.
Worked for www.beinsports.net, www.harf.com, www.islamweb.net, islam.gov.qa, islamonline.net.

Comments and Discussions