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

C#

 
GeneralRe: opening a default file browser of sorts Pin
Nick Parker29-Dec-02 14:33
protectorNick Parker29-Dec-02 14:33 
QuestionHave someone www.learnvisualstudio.net videos? Pin
gicio29-Dec-02 11:33
gicio29-Dec-02 11:33 
Question[C#] Validation class for events? Pin
gicio29-Dec-02 11:32
gicio29-Dec-02 11:32 
AnswerRe: [C#] Validation class for events? Pin
Nick Parker29-Dec-02 14:24
protectorNick Parker29-Dec-02 14:24 
GeneralRe: [C#] Validation class for events? Pin
gicio30-Dec-02 6:18
gicio30-Dec-02 6:18 
GeneralRe: [C#] Validation class for events? Pin
Nick Parker30-Dec-02 6:18
protectorNick Parker30-Dec-02 6:18 
GeneralRe: [C#] Validation class for events? Pin
gicio30-Dec-02 7:31
gicio30-Dec-02 7:31 
GeneralRe: [C#] Validation class for events? Pin
gicio2-Jan-03 7:40
gicio2-Jan-03 7:40 
Hi,

I write a new class... like this:

[CODE]

using System;
using System.Windows.Forms;
using System.Windows.Forms.ComponentModel;

namespace CarTrade
{
///
/// Summary description for TestTextBox.
///

public class TestTextBox : System.Windows.Forms.TextBox
{
private bool booOnlyNumericCharsAllowed;
private bool booSpecialKeyIsPress;

public TestTextBox.
{

}

//---------------------------------------------------------------
//---------------------------PROPERTIES--------------------------
//---------------------------------------------------------------

//we allowed in the TestTextBox only numeric chars
//when the user set the proparty OnlyOnlyNumericCharsAllowed
//to true
internal bool OnlyNumericCharsAllowed
{
get
{
//return the value how OnlyOnlyNumericCharsAllowed
//is set
return booOnlyNumericCharsAllowed;
}
set
{
if(value)
{
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.DoWhenKeyPress);
}

booOnlyNumericCharsAllowed = value;
}
}

internal bool SpecialKeyIsPress
{
get
{
return booSpecialKeyIsPress;
}
set
{
if(value)
{
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CheckIfSpecialKeysArePressed);
}

booSpecialKeyIsPress = value;
}
}

private void CheckIfSpecialKeysArePressed(object sender, System.Windows.Forms.KeyEventArgs e)
{
bool booEnter = e.KeyCode == Keys.Enter;
bool booReturn = e.KeyCode==Keys.Return;
bool booTab = e.KeyCode==Keys.Tab;

if(booEnter || booReturn || booTab)
{

}
}

private void DoWhenKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 )
{
e.Handled = true;
}

if(Text.Length == 0 && e.KeyChar == 48)
{
e.Handled = true;
}
}

}
}


[/CODE]



Any coments are welcome!


gicio
GeneralLooking for other developer boards Pin
gicio29-Dec-02 11:31
gicio29-Dec-02 11:31 
GeneralLooking for developer videos/demos/webcasts tutorials Pin
gicio29-Dec-02 11:30
gicio29-Dec-02 11:30 
GeneralRe: Looking for developer videos/demos/webcasts tutorials Pin
Anonymous25-Feb-03 4:15
Anonymous25-Feb-03 4:15 
GeneralReflection and 'ref' parameter Pin
29-Dec-02 1:03
suss29-Dec-02 1:03 
GeneralRe: Reflection and 'ref' parameter Pin
Anonymous29-Dec-02 7:41
Anonymous29-Dec-02 7:41 
QuestionModal Windows? Pin
gekoscan28-Dec-02 22:47
gekoscan28-Dec-02 22:47 
AnswerRe: Modal Windows? Pin
Stephane Rodriguez.28-Dec-02 23:36
Stephane Rodriguez.28-Dec-02 23:36 
GeneralUmm... same error Pin
gekoscan29-Dec-02 2:03
gekoscan29-Dec-02 2:03 
GeneralInsite on what i am trying to accomplish Pin
gekoscan29-Dec-02 2:10
gekoscan29-Dec-02 2:10 
GeneralRe: Insite on what i am trying to accomplish Pin
Stephane Rodriguez.29-Dec-02 3:30
Stephane Rodriguez.29-Dec-02 3:30 
GeneralMore Insite and thank you. Pin
gekoscan29-Dec-02 9:58
gekoscan29-Dec-02 9:58 
GeneralRe: More Insite and thank you. Pin
Stephane Rodriguez.29-Dec-02 20:36
Stephane Rodriguez.29-Dec-02 20:36 
Questionhelp? Pin
imran_rafique28-Dec-02 4:23
imran_rafique28-Dec-02 4:23 
AnswerRe: help? Pin
leppie28-Dec-02 5:00
leppie28-Dec-02 5:00 
GeneralAccess key for a user control Pin
jantie7828-Dec-02 3:57
sussjantie7828-Dec-02 3:57 
GeneralRe: Access key for a user control Pin
leppie28-Dec-02 5:08
leppie28-Dec-02 5:08 
GeneralRe: Access key for a user control Pin
Jan Tielens28-Dec-02 5:28
Jan Tielens28-Dec-02 5:28 

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.