Exemplo n.º 1
0
        private void repopulateList()
        {
            this.Items.Clear();

            foreach (DatabaseTable currObj in DatabaseObjects)
            {
                ListViewItem newItem = null;

                foreach (DBField currField in FieldDisplaySettings.Fields)
                {
                    if (FieldDisplaySettings.getProperties(currField.FieldName) == null ||
                        !FieldDisplaySettings.getProperties(currField.FieldName).Visible)
                    {
                        continue;
                    }

                    if (newItem == null)
                    {
                        newItem = new ListViewItem();
                        if (_displayColumns)
                        {
                            newItem.Text = currField.GetValue(currObj).ToString().Trim();
                        }
                        else
                        {
                            newItem.Text = currObj.ToString();
                        }

                        newItem.Tag = currObj;
                    }
                    else
                    {
                        ListViewItem.ListViewSubItem newSubItem = new ListViewItem.ListViewSubItem();
                        newSubItem.Text = currField.GetValue(currObj).ToString().Trim();
                        newItem.SubItems.Add(newSubItem);
                    }
                }

                if (newItem != null)
                {
                    this.Items.Add(newItem);
                }
            }

            if (autoSize)
            {
                this.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            }

            Sort();
        }
Exemplo n.º 2
0
        public void OnFieldPropertiesChanged()
        {
            if (grid.Columns.Count == 0)
            {
                return;
            }

            grid.Rows.Clear();

            foreach (DBField currField in FieldDisplaySettings.Fields)
            {
                FieldProperty properties = FieldDisplaySettings.getProperties(currField.Name);
                if (properties == null)
                {
                    properties           = new FieldProperty();
                    properties.FieldName = currField.Name;
                    properties.Visible   = true;
                }

                if (properties.Visible == false)
                {
                    continue;
                }

                int             rowNum  = grid.Rows.Add();
                DataGridViewRow currRow = grid.Rows[rowNum];
                currRow.Tag      = currField;
                currRow.ReadOnly = properties.ReadOnly;

                // build the custom value cell
                IDBFieldBackedControl valueCell;
                if (currField.DBType == DBField.DBDataType.ENUM)
                {
                    valueCell = new DBComboBoxCell();
                }
                else
                {
                    valueCell = new DBTextBoxCell();
                }

                valueCell.Table              = FieldDisplaySettings.Table;
                valueCell.DatabaseFieldName  = properties.FieldName;
                valueCell.DatabaseObject     = DatabaseObject;
                valueCell.FieldChanged      += new FieldChangedListener(OnFieldChanged);
                currRow.Cells["valueColumn"] = (DataGridViewCell)valueCell;

                currRow.Cells["fieldColumn"].Value = properties.DisplayName;
            }
        }
Exemplo n.º 3
0
        private void BuildColumns()
        {
            this.Items.Clear();
            this.Columns.Clear();

            Dictionary <FieldProperty, ColumnHeader> columnLookup = new Dictionary <FieldProperty, ColumnHeader>();

            foreach (DBField currField in FieldDisplaySettings.Fields)
            {
                FieldProperty properties = FieldDisplaySettings.getProperties(currField.Name);
                if (properties == null)
                {
                    properties           = new FieldProperty();
                    properties.FieldName = currField.Name;
                    properties.Visible   = true;
                }

                if (properties.Visible == false)
                {
                    continue;
                }


                ColumnHeader newColumn = new ColumnHeader();
                newColumn.Text = properties.DisplayName;
                newColumn.Name = properties.FieldName + "_column";
                newColumn.Tag  = currField;

                columnLookup[properties] = newColumn;

                this.Columns.Add(newColumn);

                // if we are not displaying columns we only need the first one.
                if (!_displayColumns)
                {
                    break;
                }
            }

            foreach (FieldProperty currProperty in FieldDisplaySettings.FieldProperties)
            {
                if (currProperty.ColumnWidth != null && currProperty.Visible != false)
                {
                    columnLookup[currProperty].Width = (int)currProperty.ColumnWidth;
                    autoSize = false;
                }
            }
        }