Click here to Skip to main content
16,005,120 members
Home / Discussions / C#
   

C#

 
GeneralRe: Save inside a file ArrayList code Pin
Sasuko17-Aug-05 12:16
Sasuko17-Aug-05 12:16 
GeneralRe: Save inside a file ArrayList code Pin
Guffa17-Aug-05 21:07
Guffa17-Aug-05 21:07 
GeneralRe: Save inside a file ArrayList code Pin
S. Senthil Kumar17-Aug-05 21:00
S. Senthil Kumar17-Aug-05 21:00 
GeneralRe: Save inside a file ArrayList code Pin
Sasuko17-Aug-05 21:49
Sasuko17-Aug-05 21:49 
GeneralRe: Save inside a file ArrayList code Pin
Azerax20-Aug-05 2:22
Azerax20-Aug-05 2:22 
GeneralMask the TextBox Pin
zaboboa17-Aug-05 10:11
zaboboa17-Aug-05 10:11 
GeneralRe: Mask the TextBox Pin
BammBamm17-Aug-05 10:59
BammBamm17-Aug-05 10:59 
GeneralRe: Mask the TextBox Pin
Mohamad Al Husseiny17-Aug-05 11:44
Mohamad Al Husseiny17-Aug-05 11:44 
This the modification version of MaskedTextControl from
User Interfaces in C# book
using System;
using System.Windows.Forms;
public class MaskedTextBox : TextBox
{
	private string mask;
	public string Mask
	{
		get
		{
			return mask;
		}
		set
		{
			mask = value;
			this.Text = "";
		}
	}

Protected override void OnKeyPress(KeyPressEventArgs e)
	{
if (Mask != "")
{
e.Handled = true;
string newText = this.Text;
bool finished = false;
for (int i = this.SelectionStart; i < mask.Length; i++)
{
	switch (mask[i].ToString())
	{
	case "#" :
	   if (Char.IsDigit(e.KeyChar) )
	   {
	      if(this.TextLength<mask.Length)
	      {
	        newText += e.KeyChar.ToString();
	        finished = true;
	        break;
	      }
             else
	      {
	   newText=newText.Remove(i,this.SelectionLength);
	   newText=newText.Insert(i,e.KeyChar.ToString());
           finished = true;
	   break;
	       }
	}
	else
	{
	// Invalid entry; exit and don't change the text.
	return;
	}
	default :
	// Insert the mask character.
	newText += mask[i];
	break;
	}
	if (finished)
	{ break; }
	}
	// Update the text.
	this.Text = newText;
	this.SelectionStart = this.Text.Length;
         }
	}

	protected override void OnKeyDown(KeyEventArgs e)
	{
		// Stop special characters.
		e.Handled = true;
	}
}

In the Form Load event add the following
maskTextBox.Mask = "$###,###";



MCAD
GeneralRe: Mask the TextBox Pin
zaboboa18-Aug-05 2:22
zaboboa18-Aug-05 2:22 
GeneralRe: Mask the TextBox Pin
Mohamad Al Husseiny18-Aug-05 3:20
Mohamad Al Husseiny18-Aug-05 3:20 
GeneralRe: Mask the TextBox Pin
zaboboa18-Aug-05 3:36
zaboboa18-Aug-05 3:36 
GeneralRe: Mask the TextBox Pin
Mohamad Al Husseiny18-Aug-05 3:44
Mohamad Al Husseiny18-Aug-05 3:44 
GeneralNNTP sever Pin
Mridang Agarwalla17-Aug-05 9:12
Mridang Agarwalla17-Aug-05 9:12 
GeneralRe: NNTP sever Pin
leppie17-Aug-05 23:40
leppie17-Aug-05 23:40 
Generalremoving XML entries Pin
Mridang Agarwalla17-Aug-05 8:44
Mridang Agarwalla17-Aug-05 8:44 
GeneralRe: removing XML entries Pin
BammBamm17-Aug-05 8:53
BammBamm17-Aug-05 8:53 
GeneralRe: removing XML entries Pin
Mridang Agarwalla17-Aug-05 8:57
Mridang Agarwalla17-Aug-05 8:57 
GeneralRe: removing XML entries Pin
Mridang Agarwalla17-Aug-05 9:00
Mridang Agarwalla17-Aug-05 9:00 
GeneralRe: removing XML entries Pin
Mridang Agarwalla17-Aug-05 9:02
Mridang Agarwalla17-Aug-05 9:02 
GeneralRe: removing XML entries Pin
DavidNohejl17-Aug-05 9:06
DavidNohejl17-Aug-05 9:06 
GeneralRe: removing XML entries Pin
Mridang Agarwalla17-Aug-05 9:10
Mridang Agarwalla17-Aug-05 9:10 
GeneralRe: removing XML entries Pin
BammBamm17-Aug-05 9:22
BammBamm17-Aug-05 9:22 
QuestionIs it possible to grab the entire bitmap for a Windows.Form? Pin
mullala17-Aug-05 7:39
mullala17-Aug-05 7:39 
GeneralFormat Number String Pin
zaboboa17-Aug-05 7:00
zaboboa17-Aug-05 7:00 
GeneralRe: Format Number String Pin
Steve Maier17-Aug-05 7:22
professionalSteve Maier17-Aug-05 7:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.