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

C#

 
GeneralRe: Click event problem Pin
Nick Parker30-Dec-02 1:22
protectorNick Parker30-Dec-02 1:22 
GeneralRe: Click event problem Pin
Nick Parker30-Dec-02 1:29
protectorNick Parker30-Dec-02 1:29 
Generalopening a default file browser of sorts Pin
jtmtv1829-Dec-02 12:51
jtmtv1829-Dec-02 12:51 
GeneralRe: opening a default file browser of sorts Pin
jtmtv1829-Dec-02 13:05
jtmtv1829-Dec-02 13:05 
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 
gicio wrote:
CheckWhichKeyDown and ValidateThis should be in one validation class.
How I can write a validation class that validate ALL TextBoxes from all classes.
Any ideas?


Sure, I would highly suggest this so you aren't rewriting code all the time, simply add a new class within your application, possibly like the following:
namespace test
{
  /// <summary>
  /// Summary description for Validation.
  /// </summary>
  public class Validation
  {
	public Validation()
	{}
		
	public bool CheckWhichKeyDown(System.Windows.Forms.KeyEventArgs kea)
	{	
		if(kea.KeyValue == 13)	
			return true;
		else
			return false;
	}

	public bool SomeOtherFunctionHere()
	{
		return true;
	}
  }
}


Then, say for example in any of your KeyDown event handlers you can implement it like the following, keep in mind my namespace for this example is titled test.
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
	test.Validation v = new Validation();
	if(v.CheckWhichKeyDown(e) == true)
		MessageBox.Show("You hit enter.");
	else
		MessageBox.Show("You hit " + e.KeyData.ToString());
}


The idea is that you are creating an instance of a class, your validation class, and then invoking methods against that instance. Hope this helps.





Nick Parker

You see the Standards change. - Fellow co-worker


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 
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 

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.