프로그램/C#

grid 안의 셀에서 keyDown, KeyUp, KeyPress 이벤트 처리.

(주)CKBcorp., 2018. 1. 16. 18:07
반응형

광고시작

작성시작시각 :




        private void grid1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)

        {

            e.Control.KeyUp += new KeyEventHandler(KeyUp1);

        }


        private void KeyUp1(object sender, KeyEventArgs e)

        {

            try

            {

                string tstr1;

                lbldbg1.Text = "boxup" + ++tCount + " c:" + grid1.CurrentCell.ColumnIndex + " r:" + grid1.CurrentCell.RowIndex;

                TextBox aaa;

                aaa = (TextBox)sender;

                // DataGridViewTextBoxEditingControl.

                textBox1.Text += System.Environment.NewLine + aaa.Text;

                tstr1 = aaa.Text;

                if (tstr1.Length > 4) tstr1 = Int32.Parse(tstr1.Replace(",","")).ToString("N0");

                aaa.Text = tstr1;

                aaa.Select(tstr1.Length, 0);


            }

            catch (Exception ex)

            {

                // MessageBox.Show(  ex.Message.ToString() );

                Console.WriteLine(ex.Message.ToString());

            }

        }


작성종료시각 :



반응형