0

我想在我的文本编辑上添加日期时添加一个行,自动将该日期添加到我的网格控件上,但我不知道你能帮我吗

我的代码是:

private void mTxtDateEditFchIni_EditValueChanged(object sender, EditValueChangedEventArgs e)
        {
            try
            { 
                DateTime fechaIni = Convert.ToDateTime(mTxtDateEditFchIni.Text);
                string anio = (fechaIni.Year).ToString();
                string year = (fechaIni.Year + 1).ToString();
                string month = (fechaIni.Month).ToString();
                string day = (fechaIni.Day - 1).ToString();
                DateTime fechaFin = Convert.ToDateTime(day + "/" + month + "/" + year);
                mTxtDateEditFchFin.Text = fechaFin.ToShortDateString();
                mtxtdscConfPer.Text = "Periodo " + anio + " - " + year;
                DataTable tblGrid = new DataTable();
                foreach (GridColumn col in mDetalle_grdctl.Columns)
                {
                tblGrid.Columns.Add();
                }
                string[] rwTable = new string[tblGrid.Columns.Count];
                rwTable[0] = fechaIni.ToShortDateString();
                rwTable[1] = fechaFin.ToShortDateString();

                for (int i = 2; i < rwTable.Length; i++)
                {
                    rwTable[i] = "1";
                }
                tblGrid.Rows.Add(rwTable);
                mDetalle_grdctl.ItemsSource = tblGrid;

                mDetalle_grdctl.View.IsEnabled = true;

                mDetalle_grctlvie.NewItemRowPosition = NewItemRowPosition.Bottom;
                mDetalle_grctlvie.MoveLastRow();
                mDetalle_grdctl.View.MoveLastRow();
                mDetalle_grdctl.View.AllowEditing = true;
                movar_isupdatemod = false;

            }
            catch (Exception ex)
            {
                DXMessageBox.Show(ex.Message);
            }            
        } 
4

0 回答 0