Ejemplo n.º 1
0
        private void SetResults(DataTable table, PerformAutoSizeType performAutoSizeType = PerformAutoSizeType.VisibleRows, bool showAlternateAppearance = false)
        {
            if (table == null || table.Columns.Count > 0)
            {
                _log.Debug("Binding grid ...");
                _ugGrid.DataSource = table;
                _ugGrid.SetColumnFormat(typeof(DateTime), "yyyy-MM-dd HH:mm:ss.fff");
                _ugGrid.DisplayLayout.Override.RowSelectorHeaderStyle = table != null
                                                                            ? RowSelectorHeaderStyle.ColumnChooserButton
                                                                            : RowSelectorHeaderStyle.Default;
                _log.Debug("Performing auto resize ...");
                _ugGrid.ResizeColumnsToFit(performAutoSizeType);
                _log.Debug("Binding grid complete.");
            }
            else
            {
                table.Columns.Add("Results", typeof(string));
                table.Rows.Add("Command executed successfully");
                SetResults(table, performAutoSizeType);
            }

            if (showAlternateAppearance)
            {
                SetAlternateRowAppearance();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// resized all columns in the grid to fit the contents.
        /// </summary>
        /// <param name="grid">Grid on which the resize is performed.</param>
        /// <param name="resizeType">Type of resize.</param>
        public static void ResizeColumnsToFit(this UltraGrid grid, PerformAutoSizeType resizeType = PerformAutoSizeType.AllRowsInBand)
        {
            if (grid == null)
            {
                _log.Error("Grid parameter is null.");
                throw new ArgumentNullException("grid");
            }

            if (grid.InvokeRequired)
            {
                grid.Invoke(new MethodInvoker(() => ResizeColumnsToFit(grid, resizeType)));
            }
            else
            {
                _log.Debug("Resizing grid to fit ...");
                foreach (var column in grid.DisplayLayout.Bands[0].Columns)
                {
                    column.PerformAutoResize(resizeType, true);
                }
                _log.Debug("Resizing grid complete.");
            }
        }