|
HI
I have the folloing code in my datagrid view EditingControlShowing event..
private void dataEditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridView D = sender as DataGridView; if (D.CurrentCell.ColumnIndex == 1) { TextBox txt = (TextBox)(e.Control); if (txt != null) { txt.KeyPress += new System.Windows.Forms.KeyPressEventHandler(Program.txtOnlyAllowNumericAndMinus); txt.Leave += new System.EventHandler(this.FormatText); } } else { TextBox txt = (TextBox)(e.Control); if (txt != null) { txt.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CellKeyPress); txt.Leave += new System.EventHandler(this.DoNothing); } } }
when the Leave event is executed it does evereything as I wanted it to(formats the tect of one cell in the datagridview) but for some strange reason the text gets changed back right away... I stepped through the code and there was nothing that would have changed it back...
Can anyone show me how I can format the text of the second column in a two column datagridview?
thanks
szsz
|