在GridControl中添加一个新行

时间:2013-10-01 14:55:31

标签: c# add rows gridcontrol

当我在我的textedit上添加日期时,我想添加一行,自动将该日期添加到我的gridcontrol上,但我不知道你怎么能帮助我

我的代码是:

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);
            }            
        } 

0 个答案:

没有答案