protected override void OnValidated(EventArgs e)
        {
            if (dataGridView != null && dataGridView is ExtendedDataGridView)
            {
                ExtendedDataGridView edgw = dataGridView as ExtendedDataGridView;
                edgw.ControlValidate(edgw.CurrentCell.OwningColumn.Name, this.Description);

                //if (edgw == null)
                //    MessageBox.Show("edgw");
                //if (DescriptionColumn == null)
                //    MessageBox.Show("DescriptionColumn");
                //if (edgw.CurrentRow == null)
                //    MessageBox.Show("edgw.CurrentRow");
                //if (edgw.CurrentRow.Cells == null)
                //    MessageBox.Show("edgw.CurrentRow.Cells");
                //if (edgw.CurrentRow.Cells[DescriptionColumn.Name] == null)
                //    MessageBox.Show("edgw.CurrentRow.Cells[DescriptionColumn.Name]");
                //if (edgw.CurrentRow.Cells[DescriptionColumn.Name].Value == null)
                //    MessageBox.Show("edgw.CurrentRow.Cells[DescriptionColumn.Name].Value");

                if (DescriptionColumn != null &&
                    edgw.CurrentRow.Cells[DescriptionColumn.Name] != null &&
                    edgw.CurrentRow.Cells[DescriptionColumn.Name].Value != null &&
                    edgw.CurrentRow.Cells[DescriptionColumn.Name].Value.ToString() != this.Description)
                {
                    edgw.CurrentRow.Cells[DescriptionColumn.Name].Value = this.Description;
                }
            }
            base.OnValidated(e);
        }
Exemple #2
0
        public MetroGridFooterPanel(ExtendedDataGridView metroGrid)
        {
            this.metroGrid = metroGrid;

            InitializeComponent();

            metroGrid.RowsAdded           += MetroGrid_RowsAdded;
            metroGrid.RowsRemoved         += MetroGrid_RowsRemoved;
            metroGrid.RowEnter            += MetroGrid_RowEnter;
            metroGrid.RowLeave            += MetroGrid_RowLeave;
            metroGrid.DataBindingComplete += MetroGrid_DataBindingComplete;
            metroGrid.CellValueChanged    += MetroGrid_CellValueChanged;
            metroGrid.ChangeDataSource    += MetroGrid_ChangeDataSource;

            metroGrid.Scroll += MetroGrid_Scroll;
            metroGrid.Resize += MetroGrid_Resize;

            metroGrid.ColumnWidthChanged     += MetroGrid_ColumnWidthChanged;
            metroGrid.RowHeadersWidthChanged += MetroGrid_RowHeadersWidthChanged;

            metroGrid.ColumnAdded               += MetroGrid_ColumnAdded;
            metroGrid.ColumnRemoved             += MetroGrid_ColumnRemoved;
            metroGrid.ColumnStateChanged        += MetroGrid_ColumnStateChanged;
            metroGrid.ColumnDisplayIndexChanged += MetroGrid_ColumnDisplayIndexChanged;

            Padding = new Padding(0, 2, 0, 0);
        }
        public static void Load(ExtendedDataGridView dgw)
        {
            dgw.AllowUserToOrderColumns = true;
            var gridnamespace = string.Format("{0}.{1}", dgw.DocumentForm.Name, dgw.Name);

            if (string.IsNullOrEmpty(Properties.Settings.Default.DataGridViewSetting))
            {
                return;
            }

            if (gridProperties == null)
            {
                using (System.IO.MemoryStream sw = new System.IO.MemoryStream(Encoding.UTF8.GetBytes(Properties.Settings.Default.DataGridViewSetting)))
                {
                    var serializer = new DataContractJsonSerializer(typeof(Dictionary <string, List <DataGridColumnProperties> >));
                    gridProperties = (Dictionary <string, List <DataGridColumnProperties> >)serializer.ReadObject(sw);
                    sw.Close();
                }
            }

            if (!gridProperties.ContainsKey(gridnamespace))
            {
                return;
            }

            foreach (DataGridColumnProperties column in gridProperties[gridnamespace])
            {
                dgw.Columns[column.ColumnName].DisplayIndex = column.DisplayIndex;
                dgw.Columns[column.ColumnName].Width        = column.Width;
                dgw.Columns[column.ColumnName].Visible      = column.Visible;
            }
        }
        private void CreateHeaderPanel(ExtendedDataGridView datagrid)
        {
            headerPanel = new MetroGridHeaderPanel(datagrid)
            {
                Visible    = showHeaderPanel,
                ShowFilter = showFilter
            };

            Controls.Add(headerPanel);
        }
Exemple #5
0
        public MetroGridHeaderPanel(ExtendedDataGridView metroGrid)
        {
            this.metroGrid = metroGrid;
            Dock           = System.Windows.Forms.DockStyle.Top;
            Height         = 32;
            BorderStyle    = System.Windows.Forms.BorderStyle.FixedSingle;
            Padding        = new System.Windows.Forms.Padding(3, 3, 3, 3);

            metroGrid.RowsAdded        += MetroGrid_RowsAdded;
            metroGrid.RowsRemoved      += MetroGrid_RowsRemoved;
            metroGrid.CellValueChanged += MetroGrid_CellValueChanged;
        }
        private void SetDefaults(ExtendedDataGridView datagrid)
        {
            Dock        = datagrid.Dock;
            Anchor      = datagrid.Anchor;
            Padding     = datagrid.Padding;
            Margin      = datagrid.Margin;
            Top         = datagrid.Top;
            Left        = datagrid.Left;
            BorderStyle = this.BorderStyle;
            Width       = datagrid.Width;
            Height      = datagrid.Height;

            ShowHeaderPanel = datagrid.ShowHeaderPanel;
            showFooterPanel = datagrid.ShowFooterPanel;
        }
 protected override void OnValidated(EventArgs e)
 {
     if (dataGridView != null && dataGridView is ExtendedDataGridView)
     {
         ExtendedDataGridView edgw = dataGridView as ExtendedDataGridView;
         if (edgw.CurrentCell != null)
         {
             edgw.ControlValidate(edgw.CurrentCell.OwningColumn.Name, this.Description);
             if (DescriptionColumn != null &&
                 edgw.CurrentRow.Cells[DescriptionColumn.Name] != null)
             {
                 edgw.CurrentRow.Cells[DescriptionColumn.Name].Value = this.Description;
             }
         }
     }
     base.OnValidated(e);
 }
        protected override void OnValidated(EventArgs e)
        {
            if (dataGridView is ExtendedDataGridView)
            {
                ExtendedDataGridView edgw = dataGridView as ExtendedDataGridView;

                //if (SL.ContainsKey(this.Text))
                //{
                edgw.ControlValidate(edgw.CurrentCell.OwningColumn.Name, Text);
                if (DescriptionColumn != null)
                {
                    edgw.CurrentRow.Cells[DescriptionColumn.Name].Value = GetDescription(Text);
                }

                //}
            }
            base.OnValidated(e);
        }
        public static void Save(ExtendedDataGridView dgw)
        {
            Debug.Assert(!dgw.DocumentForm.Name.IsEmpty(), "ExtendedDataGridView don't binded");
            var gridnamespace = string.Format("{0}.{1}", dgw.DocumentForm.Name, dgw.Name);

            if (gridProperties == null)
            {
                gridProperties = new Dictionary <string, List <DataGridColumnProperties> >();
            }

            if (gridProperties.ContainsKey(gridnamespace))
            {
                gridProperties[gridnamespace].Clear();
            }
            else
            {
                gridProperties.Add(gridnamespace, new List <DataGridColumnProperties>());
            }

            foreach (DataGridViewColumn column in dgw.Columns)
            {
                var dgcp = new DataGridColumnProperties
                {
                    ColumnName   = column.Name,
                    DisplayIndex = column.DisplayIndex,
                    Width        = column.Width,
                    Visible      = column.Visible
                };
                gridProperties[gridnamespace].Add(dgcp);
            }

            using (System.IO.MemoryStream sw = new System.IO.MemoryStream())
            {
                var serializer = new DataContractJsonSerializer(typeof(Dictionary <string, List <DataGridColumnProperties> >));
                serializer.WriteObject(sw, gridProperties);
                Properties.Settings.Default.DataGridViewSetting = Encoding.UTF8.GetString(sw.ToArray());
                sw.Close();
            }
            Properties.Settings.Default.Save();
        }
        public static void Delete(ExtendedDataGridView dgw)
        {
            var gridnamespace = string.Format("{0}.{1}", dgw.DocumentForm.Name, dgw.Name);

            if (gridProperties == null)
            {
                gridProperties = new Dictionary <string, List <DataGridColumnProperties> >();
            }

            if (gridProperties.ContainsKey(gridnamespace))
            {
                gridProperties[gridnamespace].Clear();
            }

            using (System.IO.MemoryStream sw = new System.IO.MemoryStream())
            {
                var serializer = new DataContractJsonSerializer(typeof(Dictionary <string, List <DataGridColumnProperties> >));
                serializer.WriteObject(sw, gridProperties);
                Properties.Settings.Default.DataGridViewSetting = Encoding.UTF8.GetString(sw.ToArray());
                sw.Close();
            }
            Properties.Settings.Default.Save();
        }
 public MetroGridContainerPanel(ExtendedDataGridView datagrid)
 {
     metroGrid = datagrid;
     SetDefaults(datagrid);
     CreateHeaderPanel(datagrid);
 }
 public MetroGridTotalFooterPanel(ExtendedDataGridView datagrid)
     : base(datagrid)
 {
     InitializeComponent();
     Height = metroGrid.RowTemplate.Height + 4;
 }