Beispiel #1
0
        public void Bug_3424()
        {
            var grid1 = new Grid();

            grid1.ColumnsCount = 3;
            grid1.FixedRows    = 1;
            grid1.Rows.Insert(0);

            SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader("String");

            // here you can se the other column to sort when the current column is equal
            header1.SortComparer = new SourceGrid.MultiColumnsComparer(1, 2);

            var sorter = new SourceGrid.Cells.ColumnHeader("CheckBox");

            grid1[0, 0] = header1;
            grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime");
            grid1[0, 2] = sorter;
            for (int r = 1; r < 10; r++)
            {
                grid1.Rows.Insert(r);
                grid1[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string));
                grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today.AddDays(7 * r), typeof(DateTime));
                grid1[r, 2] = new SourceGrid.Cells.CheckBox("", true);
            }

            grid1[9, 2]            = null;
            grid1[9, 1].ColumnSpan = 2;

            sorter.Sort(true);
        }
		public void Bug_3424()
		{
			var grid1 = new Grid();
			grid1.ColumnsCount = 3;
			grid1.FixedRows = 1;
			grid1.Rows.Insert(0);
	
			SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader("String");
	
			// here you can se the other column to sort when the current column is equal
			header1.SortComparer = new SourceGrid.MultiColumnsComparer(1, 2);
	
			var sorter = new SourceGrid.Cells.ColumnHeader("CheckBox");
			grid1[0, 0] = header1;
			grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime");
			grid1[0, 2] = sorter;
			for (int r = 1; r < 10; r++)
			{
				grid1.Rows.Insert(r);
				grid1[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string));
				grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today.AddDays(7 * r), typeof(DateTime));
				grid1[r, 2] = new SourceGrid.Cells.CheckBox("", true);
			}
			
			grid1[9, 2] = null;
			grid1[9, 1].ColumnSpan = 2;
			
			sorter.Sort(true);
		}
        private void LoadCategorySample(string category, SourceGrid.Cells.Controllers.Button linkEvents, Type[] assemblyTypes, SourceGrid.Cells.Views.IView categoryView, SourceGrid.Cells.Views.IView headerView)
        {
            int row;

            //Create Category Row
            row = grid1.RowsCount;
            grid1.Rows.Insert(row);
            grid1[row, 0]            = new SourceGrid.Cells.Cell(category);
            grid1[row, 0].View       = categoryView;
            grid1[row, 0].ColumnSpan = grid1.ColumnsCount;

            //Create Headers
            row = grid1.RowsCount;
            grid1.Rows.Insert(row);

            SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader("Sample N?");
            header1.View = headerView;
            header1.AutomaticSortEnabled = false;
            grid1[row, 0] = header1;

            SourceGrid.Cells.ColumnHeader header2 = new SourceGrid.Cells.ColumnHeader("Description");
            header2.View = headerView;
            header2.AutomaticSortEnabled = false;
            grid1[row, 1] = header2;

            //Create Data Cells
            for (int i = 0; i < assemblyTypes.Length; i++)
            {
                object[] attributes = assemblyTypes[i].GetCustomAttributes(typeof(SampleAttribute), true);
                if (attributes != null && attributes.Length > 0)
                {
                    SampleAttribute sampleAttribute = (SampleAttribute)attributes[0];

                    if (sampleAttribute.Category == category)
                    {
                        row = grid1.RowsCount;
                        grid1.Rows.Insert(row);
                        grid1[row, 0]      = new SourceGrid.Cells.Cell(sampleAttribute.SampleNumber);
                        grid1[row, 0].View = new SourceGrid.Cells.Views.Cell();
                        grid1[row, 0].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

                        //Create a cell with a link
                        grid1[row, 1]     = new SourceGrid.Cells.Link(sampleAttribute.Description);
                        grid1[row, 1].Tag = assemblyTypes[i];
                        grid1[row, 1].Controller.AddController(linkEvents);
                    }
                }
            }

            //Enable sorting of the category range
            SourceGrid.RangeLoader headerRange = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row, 0, header1.Range.Start.Row, 1));
            SourceGrid.RangeLoader rangeToSort = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row + 1, 0, row, 1));
            SourceGrid.Cells.Controllers.SortableHeader sortableController = new SourceGrid.Cells.Controllers.SortableHeader(rangeToSort, headerRange);

            header1.AddController(sortableController);
            header1.Sort(true);
            header2.AddController(sortableController);
        }
        private void LoadCategorySample(string category, SourceGrid.Cells.Controllers.Button linkEvents, Type[] assemblyTypes, SourceGrid.Cells.Views.IView categoryView, SourceGrid.Cells.Views.IView headerView)
        {
            int row;

            //Create Category Row
            row = grid1.RowsCount;
            grid1.Rows.Insert(row);
            grid1[row, 0] = new SourceGrid.Cells.Cell(category);
            grid1[row, 0].View = categoryView;
            grid1[row, 0].ColumnSpan = grid1.ColumnsCount;

            //Create Headers
            row = grid1.RowsCount;
            grid1.Rows.Insert(row);

            SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader("Sample N°");
            header1.View = headerView;
            header1.AutomaticSortEnabled = false;
            grid1[row, 0] = header1;

            SourceGrid.Cells.ColumnHeader header2 = new SourceGrid.Cells.ColumnHeader("Description");
            header2.View = headerView;
            header2.AutomaticSortEnabled = false;
            grid1[row, 1] = header2;

            //Create Data Cells
            for (int i = 0; i < assemblyTypes.Length; i++)
            {
                object[] attributes = assemblyTypes[i].GetCustomAttributes(typeof(SampleAttribute), true);
                if (attributes != null && attributes.Length > 0)
                {
                    SampleAttribute sampleAttribute = (SampleAttribute)attributes[0];

                    if (sampleAttribute.Category == category)
                    {
                        row = grid1.RowsCount;
                        grid1.Rows.Insert(row);
                        grid1[row, 0] = new SourceGrid.Cells.Cell( sampleAttribute.SampleNumber );
                        grid1[row, 0].View = new SourceGrid.Cells.Views.Cell();
                        grid1[row, 0].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

                        //Create a cell with a link
                        grid1[row, 1] = new SourceGrid.Cells.Link( sampleAttribute.Description );
                        grid1[row, 1].Tag = assemblyTypes[i];
                        grid1[row, 1].Controller.AddController(linkEvents);
                    }
                }
            }

            //Enable sorting of the category range
            SourceGrid.RangeLoader headerRange = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row, 0, header1.Range.Start.Row, 1));
            SourceGrid.RangeLoader rangeToSort = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row+1, 0, row, 1));
            SourceGrid.Cells.Controllers.SortableHeader sortableController = new SourceGrid.Cells.Controllers.SortableHeader(rangeToSort, headerRange);

            header1.AddController(sortableController);
            header1.Sort(true);
            header2.AddController(sortableController);
        }