Click here to Skip to main content
15,913,486 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: How to lay out a form with multiple views Pin
shultas30-Jul-08 9:40
shultas30-Jul-08 9:40 
GeneralRe: How to lay out a form with multiple views Pin
led mike30-Jul-08 9:58
led mike30-Jul-08 9:58 
GeneralRe: How to lay out a form with multiple views Pin
Thomas Stockwell31-Jul-08 7:26
professionalThomas Stockwell31-Jul-08 7:26 
AnswerRe: How to lay out a form with multiple views Pin
darkelv31-Jul-08 23:50
darkelv31-Jul-08 23:50 
AnswerRe: How to lay out a form with multiple views Pin
nelsonpaixao3-Aug-08 15:34
nelsonpaixao3-Aug-08 15:34 
QuestionC#.net service for printers Pin
balu1234530-Jul-08 7:31
balu1234530-Jul-08 7:31 
Questionhow to validate Gridview cell's text . Pin
squattyarun29-Jul-08 22:35
squattyarun29-Jul-08 22:35 
AnswerRe: how to validate Gridview cell's text . [modified] Pin
ElSpinos30-Jul-08 5:27
ElSpinos30-Jul-08 5:27 
You could try the following:

1 - Handle the DataGridView.EditingControlShowing event

private void DataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
 // Make sure we're getting the key press event for a text type editor...
 if (e.Control.GetType() == typeof(DataGridViewTextBoxEditingControl))
  // Handle the editing control's keypress event...
  (e.Control).KeyPress += DataGridViewTextBoxEditingControlTextBoxControl_KeyPress;
}


2 - Inside the keypress event, check for the keys you need and process them

private void DataGridViewTextBoxEditingControlTextBoxControl_KeyPress(object sender, KeyPressEventArgs e)
{
 // Standard editing keys can be processed...
 if (e.KeyChar == (char)Keys.Back)
 {
  e.Handled = false;
  // No need for further validation...
  return;
 }

 // Just evaluate the contents of the cell if the value type is int
 // NOTE: _dataGridView here is a reference to the grid in context...
 if (_dataGridView.CurrentCell.ValueType != typeof (int))
  return;

 // Validate the key char...
 // NOTE: By specifying e.Handled = true, we are indicating that
 // we absorbed the character and this key is not sent to the cell.
 e.Handled = char.IsNumber(e.KeyChar);
}


Hope this helps...

/F - .NET Developer

modified on Wednesday, July 30, 2008 11:55 AM

GeneralRe: how to validate Gridview cell's text . Pin
squattyarun2-Aug-08 1:27
squattyarun2-Aug-08 1:27 
QuestionReport Scheduler c# GUI and SQL schema help Pin
m3ntat_29-Jul-08 5:53
m3ntat_29-Jul-08 5:53 
QuestionText on Skinbutton Pin
viciouskinid29-Jul-08 5:11
viciouskinid29-Jul-08 5:11 
AnswerRe: Text on Skinbutton Pin
led mike29-Jul-08 5:25
led mike29-Jul-08 5:25 
GeneralRe: Text on Skinbutton Pin
viciouskinid29-Jul-08 12:24
viciouskinid29-Jul-08 12:24 
GeneralRe: Text on Skinbutton Pin
led mike29-Jul-08 16:54
led mike29-Jul-08 16:54 
QuestionValidation Checking Pin
Sritanu _ Ghosh27-Jul-08 21:39
Sritanu _ Ghosh27-Jul-08 21:39 
AnswerRe: Validation Checking Pin
Paul Conrad28-Jul-08 5:46
professionalPaul Conrad28-Jul-08 5:46 
GeneralRe: Validation Checking Pin
Sritanu _ Ghosh28-Jul-08 21:30
Sritanu _ Ghosh28-Jul-08 21:30 
AnswerRe: Validation Checking Pin
dan!sh 28-Jul-08 22:09
professional dan!sh 28-Jul-08 22:09 
QuestionAfter debugging windows application getting error Pin
gtag27-Jul-08 20:05
gtag27-Jul-08 20:05 
AnswerRe: After debugging windows application getting error Pin
Paul Conrad28-Jul-08 17:56
professionalPaul Conrad28-Jul-08 17:56 
GeneralRe: After debugging windows application getting error Pin
gtag28-Jul-08 19:32
gtag28-Jul-08 19:32 
QuestionDesigning a multiple row input table Pin
Manuel Montoya27-Jul-08 15:08
Manuel Montoya27-Jul-08 15:08 
AnswerRe: Designing a multiple row input table Pin
Paul Conrad4-Aug-08 10:44
professionalPaul Conrad4-Aug-08 10:44 
QuestionNew to C# Pin
viciouskinid26-Jul-08 20:09
viciouskinid26-Jul-08 20:09 
AnswerRe: New to C# Pin
Manuel Montoya27-Jul-08 15:14
Manuel Montoya27-Jul-08 15:14 

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.