Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 18:32
nidhelp4-Aug-05 18:32 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 18:56
protectorChristian Graus4-Aug-05 18:56 
GeneralRe: conditions problem Pin
Luis Alonso Ramos4-Aug-05 19:12
Luis Alonso Ramos4-Aug-05 19:12 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 19:16
nidhelp4-Aug-05 19:16 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 19:23
protectorChristian Graus4-Aug-05 19:23 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 19:37
nidhelp4-Aug-05 19:37 
GeneralRe: conditions problem Pin
Christian Graus4-Aug-05 19:45
protectorChristian Graus4-Aug-05 19:45 
GeneralRe: conditions problem Pin
Weiye Chen4-Aug-05 17:51
Weiye Chen4-Aug-05 17:51 
If you are using a textbox, you can handle the key press event and process the necessary logic to allow/disallow certain characters from being entered. Here's some code below. I have not tested it but the logic is there i believe:
private void tbEditor_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
   // Always allow processing of backspace character
   if(e.KeyChar == (char)8)
      e.Handled = false;
 
   // Let system process key if it is a letter and we are now entering the 1st or 9th character
   else if(Char.IsLetter(e.KeyChar) == true && (tbEditor.Text.Length == 0 || tbEditor.Text.Length == 8))
      e.Handled = false;
 
   // Let system process key if it is a digit and we are now entering the 2nd to 8th character
   else if(Char.IsDigit(e.KeyChar) == true && (tbEditor.Text.Length > 0 || tbEditor.Text.Length < 8))
      e.Handled = false;
 
   // Do not process anything else
   else
      e.Handled = true;
}


<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 18:41
nidhelp4-Aug-05 18:41 
GeneralRe: conditions problem Pin
J4amieC4-Aug-05 22:39
J4amieC4-Aug-05 22:39 
GeneralRe: conditions problem Pin
nidhelp4-Aug-05 23:24
nidhelp4-Aug-05 23:24 
GeneralRe: conditions problem Pin
J4amieC4-Aug-05 23:46
J4amieC4-Aug-05 23:46 
GeneralRe: conditions problem Pin
nidhelp5-Aug-05 0:02
nidhelp5-Aug-05 0:02 
GeneralRe: conditions problem Pin
mav.northwind5-Aug-05 2:59
mav.northwind5-Aug-05 2:59 
GeneralRe: conditions problem Pin
nidhelp7-Aug-05 15:14
nidhelp7-Aug-05 15:14 
GeneralRe: conditions problem Pin
nidhelp5-Aug-05 0:00
nidhelp5-Aug-05 0:00 
GeneralRe: conditions problem Pin
J4amieC5-Aug-05 0:18
J4amieC5-Aug-05 0:18 
Generalabout finding forms Pin
papyrus_lei4-Aug-05 16:34
papyrus_lei4-Aug-05 16:34 
GeneralRe: about finding forms Pin
Mohamad Al Husseiny4-Aug-05 17:15
Mohamad Al Husseiny4-Aug-05 17:15 
GeneralRe: about finding forms Pin
papyrus_lei4-Aug-05 17:25
papyrus_lei4-Aug-05 17:25 
GeneralRe: about finding forms Pin
Mohamad Al Husseiny4-Aug-05 17:27
Mohamad Al Husseiny4-Aug-05 17:27 
GeneralRe: about finding forms Pin
Mohamad Al Husseiny4-Aug-05 17:47
Mohamad Al Husseiny4-Aug-05 17:47 
GeneralRe: about finding forms Pin
papyrus_lei4-Aug-05 18:02
papyrus_lei4-Aug-05 18:02 
GeneralRe: about finding forms Pin
Mohamad Al Husseiny4-Aug-05 18:05
Mohamad Al Husseiny4-Aug-05 18:05 
QuestionExcluding xsd files from documentation Pin
David Wong4-Aug-05 11:22
David Wong4-Aug-05 11: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.