Click here to Skip to main content
15,940,550 members
Home / Discussions / C#
   

C#

 
QuestionC# Textbox Pin
Pavlex49-Dec-16 6:57
Pavlex49-Dec-16 6:57 
AnswerRe: C# Textbox Pin
Michael_Davies9-Dec-16 7:03
Michael_Davies9-Dec-16 7:03 
GeneralRe: C# Textbox Pin
Pavlex49-Dec-16 7:06
Pavlex49-Dec-16 7:06 
GeneralRe: C# Textbox Pin
Michael_Davies9-Dec-16 7:29
Michael_Davies9-Dec-16 7:29 
GeneralRe: C# Textbox Pin
Pavlex49-Dec-16 7:41
Pavlex49-Dec-16 7:41 
GeneralRe: C# Textbox Pin
Eddy Vluggen9-Dec-16 8:01
professionalEddy Vluggen9-Dec-16 8:01 
GeneralRe: C# Textbox Pin
Michael_Davies9-Dec-16 8:23
Michael_Davies9-Dec-16 8:23 
AnswerRe: C# Textbox Pin
Gerry Schmitz9-Dec-16 8:26
mveGerry Schmitz9-Dec-16 8:26 
WPF or Windows Forms?

I had to code a "numerics" only TextBox in WPF the other day (PreviewKeyDown event):
private void uxRunCount_PreviewKeyDown( object sender, System.Windows.Input.KeyEventArgs e ) {

   bool ok = IsNumeric( e.Key );

   if ( !ok ) {
      e.Handled = true;    // Reject change.
   }
}

private bool IsNumeric( Key key ) {

   if ( key == Key.Back || key == Key.Delete ) { return true; }
   if ( key == Key.Tab || key == Key.Return ) { return true; }

   if ( key >= Key.D0 && key <= Key.D9 ) { return true; }
   if ( key >= Key.NumPad0 && key <= Key.NumPad9 ) { return true; }

   return false;
}

AnswerRe: C# Textbox Pin
OriginalGriff9-Dec-16 8:27
mveOriginalGriff9-Dec-16 8:27 
GeneralRe: C# Textbox Pin
Pavlex49-Dec-16 22:06
Pavlex49-Dec-16 22:06 
GeneralRe: C# Textbox Pin
OriginalGriff9-Dec-16 22:21
mveOriginalGriff9-Dec-16 22:21 
GeneralRe: C# Textbox Pin
Pavlex49-Dec-16 23:07
Pavlex49-Dec-16 23:07 
GeneralRe: C# Textbox Pin
OriginalGriff9-Dec-16 23:38
mveOriginalGriff9-Dec-16 23:38 
GeneralRe: C# Textbox Pin
Pavlex410-Dec-16 0:09
Pavlex410-Dec-16 0:09 
GeneralRe: C# Textbox Pin
OriginalGriff10-Dec-16 0:24
mveOriginalGriff10-Dec-16 0:24 
GeneralRe: C# Textbox Pin
Pavlex410-Dec-16 0:26
Pavlex410-Dec-16 0:26 
GeneralRe: C# Textbox Pin
OriginalGriff10-Dec-16 0:41
mveOriginalGriff10-Dec-16 0:41 
GeneralRe: C# Textbox Pin
Pavlex410-Dec-16 0:46
Pavlex410-Dec-16 0:46 
GeneralRe: C# Textbox Pin
OriginalGriff10-Dec-16 0:59
mveOriginalGriff10-Dec-16 0:59 
GeneralRe: C# Textbox Pin
Pavlex410-Dec-16 1:08
Pavlex410-Dec-16 1:08 
GeneralRe: C# Textbox Pin
OriginalGriff10-Dec-16 1:12
mveOriginalGriff10-Dec-16 1:12 
GeneralRe: C# Textbox Pin
Pavlex410-Dec-16 1:22
Pavlex410-Dec-16 1:22 
GeneralRe: C# Textbox Pin
OriginalGriff10-Dec-16 1:44
mveOriginalGriff10-Dec-16 1:44 
QuestionNew to c# Pin
Member 19561089-Dec-16 4:14
Member 19561089-Dec-16 4:14 
AnswerRe: New to c# Pin
ZurdoDev9-Dec-16 4:54
professionalZurdoDev9-Dec-16 4:54 

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.