Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 14th, 2007, 02:48 PM
Authorized User
Join Date: Sep 2005
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataGridViewTextBoxEditingControl adding numeric t

I have the following code

/// Puts the current cell in edit mode.
 private void monitorDataGrid_CellEnter(object sender, DataGridViewCellEventArgs e)
            validFormat = true;
            monitorDataGrid.EditMode = DataGridViewEditMode.EditOnEnter;

       /// Occurs when a control for editing a cell is showing.
        /// Performs custom initialization of the editing control when a cell enters edit mode
        private void monitorDataGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
            Control ctl = e.Control;

            DataGridViewTextBoxEditingControl dText = (DataGridViewTextBoxEditingControl)ctl;
            dText.EditingControlDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;
            dText.KeyDown += new KeyEventHandler(dText_KeyDown);
            dText.KeyUp += new KeyEventHandler(dText_KeyUp);

void dText_KeyDown(object sender, KeyEventArgs e)
            monitorDataGrid.CurrentCell.ErrorText = String.Empty;

            if (e.KeyData == Keys.OemPeriod || e.KeyData == Keys.Decimal)

            else if (
                     ((int)e.KeyCode >= (int)Keys.D0 && (int)e.KeyCode <= (int)Keys.D9) ||
                     ((int)e.KeyCode >= (int)Keys.NumPad0 && (int)e.KeyCode <= (int)Keys.NumPad9)
                DataGridViewTextBoxEditingControl dText = (DataGridViewTextBoxEditingControl)sender;

                e.Handled = false;

                // This is needed for text to go 123 instead of 321

For some reason when i run this code if i press a button and the button put an error text in my cell, when i go back , it selects all the text (something selects it not me ) and if i type a number, it will add a number at the end of the current number in the cell

For example
I have in a datagridviewcell the value 1.000

I press a button and puts an error text in the datagridviewcell

i go back and select the value 1.000 and if i press 2 it will put
if i press 2 again it will put
if i press 2 again it will put

** Disclaimer : There's nothing in my code that adds the current value of the cell ... I believe this is a bug of this control

The point is that there's a bug either in my code or in the control that causes this
what should happen is that if i press 2 it should either delete 1.000 and put 2 , or simply append the 2 at the end



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
From numeric to alfa numeric ebekir XSLT 1 August 10th, 2007 06:13 AM
How can i know it's NUMERIC deco Beginning VB 6 1 April 23rd, 2007 06:19 AM
HELP!! Numeric Textbox value quentinuys HTML Code Clinic 3 December 18th, 2006 08:04 AM
Adding Numeric TextBox Values virajoza HTML Code Clinic 1 December 18th, 2006 07:59 AM
Numeric Up Down Kunkel General .NET 0 April 16th, 2004 10:07 AM

All times are GMT -4. The time now is 11:26 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.