Click here to Skip to main content
15,886,067 members
Home / Discussions / C#
   

C#

 
GeneralRe: Data Table Error Pin
Alomgir Miah9-Sep-05 13:37
Alomgir Miah9-Sep-05 13:37 
AnswerRe: Data Table Error Pin
Guffa9-Sep-05 13:38
Guffa9-Sep-05 13:38 
QuestionRe: HELP Pin
Expert Coming9-Sep-05 13:53
Expert Coming9-Sep-05 13:53 
AnswerRe: HELP Pin
Alomgir Miah9-Sep-05 14:35
Alomgir Miah9-Sep-05 14:35 
GeneralRe: HELP Pin
Expert Coming9-Sep-05 15:08
Expert Coming9-Sep-05 15:08 
QuestionEXCEL CHART HELP! Pin
dgap9-Sep-05 11:06
dgap9-Sep-05 11:06 
QuestionHours Minutes Seconds Pin
PHDENG819-Sep-05 10:58
PHDENG819-Sep-05 10:58 
AnswerRe: Hours Minutes Seconds Pin
Mohamad Al Husseiny9-Sep-05 14:47
Mohamad Al Husseiny9-Sep-05 14:47 
You need to use masked textbox search for one to get your request or use the following class as start to develop your one.this class will masked by 00:00:00
public class MaskedTextBox : TextBox
{
	private string mask;
	public string Mask
	{
		get
		{
			return mask;
		}
		set
		{
			mask = value;
			this.Text = mask;
		}
	}

	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 "0" :
						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;
	}
}

Create instance from this class and set its mask property
maskedText.Mask="00:00:00";Note: you need to add more code to handle other keys like bakspase and other things

MCAD

-- modified at 20:49 Friday 9th September, 2005
QuestionRemoving new lines from a string Pin
Luis Alonso Ramos9-Sep-05 10:56
Luis Alonso Ramos9-Sep-05 10:56 
AnswerRe: Removing new lines from a string Pin
Guffa9-Sep-05 11:22
Guffa9-Sep-05 11:22 
GeneralRe: Removing new lines from a string Pin
Luis Alonso Ramos9-Sep-05 14:13
Luis Alonso Ramos9-Sep-05 14:13 
AnswerRe: Removing new lines from a string Pin
Kujtim Hyseni9-Sep-05 12:54
Kujtim Hyseni9-Sep-05 12:54 
AnswerRe: Removing new lines from a string Pin
Kujtim Hyseni9-Sep-05 12:58
Kujtim Hyseni9-Sep-05 12:58 
QuestionWant to display text vertically? Pin
...---...9-Sep-05 10:54
...---...9-Sep-05 10:54 
AnswerRe: Want to display text vertically? Pin
Kujtim Hyseni9-Sep-05 12:48
Kujtim Hyseni9-Sep-05 12:48 
AnswerRe: Want to display text vertically? Pin
Kujtim Hyseni9-Sep-05 12:54
Kujtim Hyseni9-Sep-05 12:54 
AnswerRe: Want to display text vertically? Pin
Mohamad Al Husseiny9-Sep-05 14:11
Mohamad Al Husseiny9-Sep-05 14:11 
GeneralRe: Want to display text vertically? Pin
Anonymous9-Sep-05 16:39
Anonymous9-Sep-05 16:39 
Questiondate format (UK) Pin
pedros739-Sep-05 9:52
pedros739-Sep-05 9:52 
AnswerRe: date format (UK) Pin
Guffa9-Sep-05 11:38
Guffa9-Sep-05 11:38 
QuestionXML deserializer question Pin
Tom Wright9-Sep-05 9:47
Tom Wright9-Sep-05 9:47 
AnswerRe: XML deserializer question Pin
Judah Gabriel Himango9-Sep-05 10:24
sponsorJudah Gabriel Himango9-Sep-05 10:24 
General[Message Deleted] Pin
Tom Wright9-Sep-05 11:34
Tom Wright9-Sep-05 11:34 
GeneralRe: [Msg Deleted] Pin
Judah Gabriel Himango9-Sep-05 11:39
sponsorJudah Gabriel Himango9-Sep-05 11:39 
GeneralRe: [Msg Deleted] Pin
Tom Wright9-Sep-05 11:56
Tom Wright9-Sep-05 11:56 

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.