Exemplo n.º 1
0
        private void T_EarningsDataGridview_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if ((e.ColumnIndex == 10 || e.ColumnIndex == 11) && e.RowIndex >= 0)
            {
                DTP.CustomFormat = "yyyy/MM/dd";
                DTP.CustomFormat = " ";

                if (T_EarningsDataGridview.CurrentCell.Value != null)
                {
                    DTP.Text = T_EarningsDataGridview.CurrentCell.Value.ToString();
                }
                else
                {
                    DTP.Value        = DateTime.Now;
                    DTP.CustomFormat = " ";
                }

                _Rectangle   = T_EarningsDataGridview.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                DTP.Size     = new Size(_Rectangle.Width, _Rectangle.Height);
                DTP.Location = new Point(_Rectangle.X, _Rectangle.Y);
                DTP.Visible  = true;
            }
            else
            {
                DTP.Visible = false;
            }
        }
        private void AddRow_Btn_Click(object sender, EventArgs e)
        {
            addNewRowNumber = T_EarningsDataGridview.Rows.Count;

            DataTable dt = T_EarningsDataGridview.DataSource as DataTable;

            //新しい行を追加」
            DataRow row = dt.NewRow();

            //行を データテーブルに入力
            dt.Rows.Add(row);

            T_EarningsDataGridview.Rows[addNewRowNumber].Cells[0].Value = addNewRowNumber + 1;
            int LastRow = T_EarningsDataGridview.Rows.GetLastRow(DataGridViewElementStates.Visible);

            T_EarningsDataGridview.ClearSelection();

            //最後行 を選択
            T_EarningsDataGridview.Rows[LastRow].Selected          = true;
            T_EarningsDataGridview.FirstDisplayedScrollingRowIndex = T_EarningsDataGridview.RowCount - 1;
        }