コード例 #1
0
        /// <summary>
        /// Inicializa os filtros dentro do grid de forma dinamica conforme cadastro realizado.
        /// </summary>
        /// <param name="filters"></param>
        private void InitializeFilters(IList <Filter> filters)
        {
            // Utilizo objeto padrão para apenas usar o recurso de gerar lista apartir de um enum
            var sComboBox = new SComboBox();

            sComboBox.SetEnumItems <TypeFilter>(TypeFilter.InitiatedBy);

            GridFilter.Clear();

            foreach (var item in filters)
            {
                var row = new DataGridViewRow()
                {
                    Tag = item
                };

                var comboBox = new DataGridViewComboBoxCell
                {
                    ValueMember   = sComboBox.ValueMember,
                    DisplayMember = sComboBox.DisplayMember,
                    DataSource    = sComboBox.SComponent.DataSource
                };

                row.Cells.Add(new DataGridViewTextBoxCell());
                row.Cells.Add(new DataGridViewTextBoxCell());
                row.Cells.Add(new DataGridViewTextBoxCell());
                row.Cells.Add(new DataGridViewTextBoxCell());

                row.Cells[1]       = comboBox;
                row.Cells[1].Value = item.DefaultTypeFilter;

                switch (item.TypeComponent)
                {
                case TypeFilterComponent.TextBox:
                    row.Cells[0].Value    = item.Display;
                    row.Cells[0].ReadOnly = true;
                    row.Cells[2]          = new DataGridViewTextBoxCell();
                    row.Cells[3]          = new DataGridViewTextBoxCell();
                    break;

                case TypeFilterComponent.ComboBox:
                    break;

                case TypeFilterComponent.Date:
                    row.Cells[0].Value    = item.Display;
                    row.Cells[0].ReadOnly = true;
                    row.Cells[2]          = new CalendarCell();
                    row.Cells[3]          = new CalendarCell();
                    break;

                case TypeFilterComponent.Time:
                    break;

                case TypeFilterComponent.DateTime:
                    break;

                case TypeFilterComponent.CheckBox:
                    break;

                case TypeFilterComponent.Numeric:
                    break;

                default:
                    break;
                }

                row.Cells[3].ReadOnly = item.DefaultTypeFilter != TypeFilter.Between;

                GridFilter.SComponent.Rows.Add(row);
            }

            GridFilter.SComponent.Refresh();
        }