replacing char during digit on datagridview

Hi all :)

Here is my problem:



private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            dataGridView1.EditingControl.KeyPress += new KeyPressEventHandler(EditingControl_KeyPress);
           
        }

        void EditingControl_KeyPress(Object o, KeyPressEventArgs e)
        {

            char myChar = '.';
            if (e.KeyChar == myChar)
            {
                e.KeyChar.ToString().Replace(myChar, ',');
                e.Handled = true;
            }
        }

 

But doesnt work. This code simply prevent user to insert '.'.
I need to replace "on the fly" the char '.' with the char ','.

Thx in advance.



Answer this question

replacing char during digit on datagridview

  • FrenchiInLA

    so....just solved:

    char myChar = '.';
    char nChar = ',';
    if(e.KeyChar == myChar)
    {
        e.KeyChar = nChar;
        e.Handled = false;
    }


  • replacing char during digit on datagridview