Ejemplo n.º 1
0
        /// <summary>
        /// Sets up columns collection.
        /// </summary>
        /// <param name="grid">The grid.</param>
        private static void SetUpColumnsCollection(GridTreeControl grid)
        {
            //need to specify the columns you want to see in the grid as well as their order
            GridTreeColumn tc = new GridTreeColumn("FirstName", "First Name", 100);

            grid.Columns.Add(tc); //0
            tc = new GridTreeColumn("LastName", "Last Name", 100);
            tc.PercentWidth = 1;
            grid.Columns.Add(tc);
            tc = new GridTreeColumn("Department", "Department", 100);
            tc.PercentWidth = 1;
            grid.Columns.Add(tc); //3
            tc = new GridTreeColumn("Salary", "Salary", 80);
            tc.StyleInfo.HorizontalAlignment = HorizontalAlignment.Right;
            tc.PercentWidth            = 1;
            tc.StyleInfo.CellValueType = typeof(double);
            tc.StyleInfo.Format        = "0,000";
            grid.Columns.Add(tc); //4
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the Loaded event of the AssociatedObject control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        void AssociatedObject_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            /// Removing Resource Column from the Grid(Table)
            for (int i = 0; i < this.AssociatedObject.GanttGrid.Columns.Count; i++)
            {
                if (this.AssociatedObject.GanttGrid.Columns[i].MappingName == "Resource")
                {
                    /// Removing Resource Column from the Grid(Table)
                    this.AssociatedObject.GanttGrid.Columns.RemoveAt(i);
                }
            }

            /// Fetching the Progress Column from the Grid(Table)
            GridTreeColumn progColumn = this.AssociatedObject.GanttGrid.Columns[5];

            /// Changing the cell type of progress Column
            progColumn.StyleInfo = new GridStyleInfo
            {
                CellType   = "UpDownEdit",
                UpDownEdit = new GridUpDownEditStyleInfo {
                    MaxValue = 100, MinValue = 0, Step = 5
                }
            };

            /// Removing and reinserting the progress column in possition 2
            this.AssociatedObject.GanttGrid.Columns.Remove(progColumn);
            this.AssociatedObject.GanttGrid.Columns.Insert(2, progColumn);

            /// Creating a new custom column of Risk percentage
            GridTreeColumn column = new GridTreeColumn
            {
                MappingName = "RiskPercentage",
                HeaderText  = "Risk",
                Width       = 100,
                StyleInfo   = new GridStyleInfo
                {
                    CellType            = "DataBoundTemplate",
                    CellItemTemplateKey = "RiskCell"
                }
            };

            /// Inserting the custom columns to GanttGrid(Table)
            this.AssociatedObject.GanttGrid.Columns.Insert(2, column);

            /// Creating a new custom column of IsCompleted
            GridTreeColumn column1 = new GridTreeColumn
            {
                MappingName = "IsComplted",
                HeaderText  = "IsCompleted",
                Width       = 40,
                StyleInfo   = new GridStyleInfo
                {
                    CellType            = "CheckBox",
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                }
            };

            /// Inserting the custom columns to GanttGrid(Table)
            this.AssociatedObject.GanttGrid.Columns.Insert(2, column1);

            this.AssociatedObject.GanttGrid.RequestNodeImage += new GridTreeRequestNodeImageHandler(GanttGrid_RequestNodeImage);
            this.AssociatedObject.GanttGrid.SupportNodeImages = true;
        }