/// <summary>
        /// Main method to initialise the grid and label on a specified tab
        /// </summary>
        /// <param name="ATableName"></param>
        /// <param name="AGrid"></param>
        /// <param name="ADescriptionLabel"></param>
        private void InitialiseTab(KeyboardShortcutTableNames ATableName, TSgrdDataGrid AGrid, Label ADescriptionLabel)
        {
            if (AGrid == null)
            {
                // The grid has already been initialised so we have nothing to do
                return;
            }

            ADescriptionLabel.AutoSize = false;
            ADescriptionLabel.Width = this.Width - 40;
            ADescriptionLabel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

            switch (ATableName)
            {
                case KeyboardShortcutTableNames.General:
                    ADescriptionLabel.Text = ApplWideResourcestrings.StrKeysHelpCategoryGeneral;
                    break;

                case KeyboardShortcutTableNames.List:
                    ADescriptionLabel.Text = ApplWideResourcestrings.StrKeysHelpCategoryList;
                    break;

                case KeyboardShortcutTableNames.Navigation:
                    ADescriptionLabel.Text = ApplWideResourcestrings.StrKeysHelpCategoryNavigation;
                    break;

                case KeyboardShortcutTableNames.FilterFind:
                    ADescriptionLabel.Text = ApplWideResourcestrings.StrKeysHelpCategoryFilterFind;
                    break;
            }

            DataTable table = FMainDS.Tables[ATableName.ToString()];

            AGrid.AddTextColumn(FColumnNames[0], table.Columns[0], 100);
            AGrid.AddTextColumn(FColumnNames[1], table.Columns[1], 250);
            AGrid.AutoStretchColumnsToFitWidth = true;
            AGrid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.None;
            AGrid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableStretch | SourceGrid.AutoSizeMode.EnableAutoSize;

            table.DefaultView.AllowNew = false;
            AGrid.DataSource = new DevAge.ComponentModel.BoundDataView(table.DefaultView);
            AGrid.AutoSizeCells(new SourceGrid.Range(1, 1, AGrid.Rows.Count - 1, 1));

            // We need this line, otherwise the Enter key locks up the screen.  For this grid, on a dialog, we have no special keys.
            AGrid.SpecialKeys = SourceGrid.GridSpecialKeys.None;
        }
Esempio n. 2
0
        /// <summary>
        /// Try to populate the grid with the current result.
        /// </summary>
        /// <returns>s false if no detail report is available
        /// </returns>
        public Boolean PopulateResultGrid(TSgrdDataGrid ASgGridView)
        {
            Boolean ReturnValue;
            DataTable t;
            DataRow row;
            Int32 i;
            Int32 counter;
            Int32 columnCounter;
            string caption;
            ArrayList sortedList;
            bool display;

            ReturnValue = true;
            FGridView = ASgGridView;

            // only do this if there are detail reports available
            // this is to prevent bugs that are still happening (same column caption etc)
            if (!parameters.Exists("param_detail_report_0"))
            {
                return false;
            }

            results.SortChildren();
            sortedList = new ArrayList();
            results.CreateSortedListByMaster(sortedList, 0);

            // create columns
            // todo: header left
            // todo: indented columns
            t = new DataTable();
            columnCounter = 0;
            t.Columns.Add("id");

            for (i = 0; i <= results.GetMaxDisplayColumns() - 1; i += 1)
            {
                if ((!parameters.Get("ColumnCaption", i).IsNil()))
                {
                    caption =
                        (parameters.Get("ColumnCaption",
                             i).ToString() + ' ' +
                         parameters.Get("ColumnCaption2", i).ToString(false) + ' ' + parameters.Get("ColumnCaption3", i).ToString(false)).Trim();

                    // todo: add i for preventing same name columns (finance reports, long captions)
                    if (t.Columns.Contains(caption))
                    {
                        caption = caption + i.ToString();
                    }
                }
                else
                {
                    caption = "Column" + i.ToString();
                }

                /* if useIndented then
                 * begin
                 * columnCounter := ColumnCounter + 1;
                 * t.Columns.Add(caption + 'Indented');
                 * end;
                 */
                t.Columns.Add(caption);
                columnCounter = columnCounter + 1;
            }

            foreach (TResult element in sortedList)
            {
                if (element.display)
                {
                    row = t.NewRow();
                    display = false;
                    row[0] = element.code;

                    for (i = 0; i <= results.GetMaxDisplayColumns() - 1; i += 1)
                    {
                        if ((element.column[i] != null) && (!element.column[i].IsNil()))
                        {
                            display = true;
                            row[i + 1] = element.column[i].ToString();
                        }
                    }

                    if (display)
                    {
                        t.Rows.Add(row);
                    }
                }
            }

            FGridView.Columns.Clear();
            FGridView.AddTextColumn(t.Columns[0].ColumnName, t.Columns[0], 0);

            for (counter = 0; counter <= parameters.Get("MaxDisplayColumns").ToInt() - 1; counter += 1)
            {
                FGridView.AddTextColumn(t.Columns[counter + 1].ColumnName, t.Columns[counter + 1]);
            }

            FGridView.DataSource = new DevAge.ComponentModel.BoundDataView(new DataView(t));
            ((DevAge.ComponentModel.BoundDataView)FGridView.DataSource).AllowEdit = false;
            ((DevAge.ComponentModel.BoundDataView)FGridView.DataSource).AllowNew = false;
            ((DevAge.ComponentModel.BoundDataView)FGridView.DataSource).AllowDelete = false;
            FGridView.AutoSizeCells();

            // FGridView.Width := 576;   it is necessary to reassign the width because the columns don't take up the maximum width
            return ReturnValue;
        }