Exemplo n.º 1
0
        public static void SetColumnsSettingsFromOptions(ConfigBase options, DataGridViewColumnCollection columns)
        {
            bool reorderDone = false;

            //set column property as saved in options
            foreach (DataGridViewColumn column in columns)
            {
                ColumnSettings settings = options.Get <ColumnSettings>(column.Name);
                if (settings == null)
                {
                    continue;
                }

                if (column.Resizable == DataGridViewTriState.True)
                {
                    column.Width = settings.Width;
                }
                column.Visible = settings.Visible;
                if (column.DisplayIndex != settings.DisplayIndex && settings.DisplayIndex < columns.Count)
                {
                    reorderDone         = true;
                    column.DisplayIndex = settings.DisplayIndex;
                }
            }

            //reschedule according to properties
            int loop = 0;

            while (reorderDone && loop < 10)
            {
                loop++;
                reorderDone = false;
                foreach (DataGridViewColumn column in columns)
                {
                    ColumnSettings settings = options.Get <ColumnSettings>(column.Name);
                    if (settings != null && column.DisplayIndex != settings.DisplayIndex && settings.DisplayIndex < columns.Count)
                    {
                        reorderDone         = true;
                        column.DisplayIndex = settings.DisplayIndex;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void LoadHistoryFromOptions()
        {
            string optionName = this.Name;

            if (optionName[1] == '_')
            {
                optionName = optionName.Substring(2);
            }

            optionName = string.Format("{0}{1}History",
                                       char.ToUpper(optionName[0]), optionName.Substring(1));

            m_history          = m_options.Get <HistoryCollection>(optionName);
            m_history.Modified = true;
        }