Ejemplo n.º 1
0
        private void SetView(ViewDefinitionInfo info)
        {
            currentViewInfo = info;

            this.radGridView1.FilterDescriptors.Clear();

            this.radGridView1.BeginUpdate();

            foreach (GridViewColumn col in this.radGridView1.Columns)
            {
                col.IsVisible = info.Columns.Contains(col.Name);
            }

            GridTraverser traverser = new GridTraverser(this.radGridView1.MasterView);

            while (traverser.MoveNext())
            {
                if (traverser.Current is GridViewDataRowInfo)
                {
                    traverser.Current.Height = info.RowHeight;
                }
            }

            this.radGridView1.MasterView.TableHeaderRow.Height = info.HeaderHeight;

            this.radGridView1.EndUpdate(false);

            this.radGridView1.ViewDefinition          = info.ViewDefinition;
            this.radGridView1.PrintStyle.FitWidthMode = PrintFitWidthMode.NoFitCentered;
        }
Ejemplo n.º 2
0
        private void InitializeGrid()
        {
            this.radGridView1.Columns["FirstName"].Width        = 80;
            this.radGridView1.Columns["LastName"].Width         = 80;
            this.radGridView1.Columns["Title"].Width            = 120;
            this.radGridView1.Columns["Photo"].Width            = 80;
            this.radGridView1.Columns["Photo"].ImageLayout      = ImageLayout.Stretch;
            this.radGridView1.Columns["City"].Width             = 70;
            this.radGridView1.Columns["Country"].Width          = 70;
            this.radGridView1.Columns["Address"].Width          = 200;
            this.radGridView1.Columns["Notes"].Width            = 260;
            this.radGridView1.Columns["Notes"].WrapText         = true;
            this.radGridView1.Columns["BirthDate"].FormatString = "{0:d}";
            this.radGridView1.Columns["BirthDate"].Width        = 120;
            this.radGridView1.Columns["HireDate"].FormatString  = "{0:d}";
            ((GridViewTextBoxColumn)this.radGridView1.Columns["Notes"]).Multiline = true;

            tableViewInfo = new ViewDefinitionInfo();
            tableViewInfo.ViewDefinition = (TableViewDefinition)this.radGridView1.ViewDefinition;
            tableViewInfo.Columns        = new List <string>()
            {
                "FirstName", "LastName", "Title", "Country", "HomePhone", "Address", "Check", "Combo"
            };

            // column groups view
            ColumnGroupsViewDefinition cgv = new ColumnGroupsViewDefinition();

            columnGroupViewInfo = new ViewDefinitionInfo();
            columnGroupViewInfo.ViewDefinition = cgv;
            columnGroupViewInfo.Columns        = new List <string>()
            {
                "Photo", "FirstName", "LastName", "Title", "Address", "City", "Country", "HomePhone", "Notes"
            };
            columnGroupViewInfo.RowHeight    = 90;
            columnGroupViewInfo.HeaderHeight = 60;

            cgv.ColumnGroups.Add(new GridViewColumnGroup());
            cgv.ColumnGroups.Add(new GridViewColumnGroup("General"));
            cgv.ColumnGroups.Add(new GridViewColumnGroup("Details"));
            cgv.ColumnGroups.Add(new GridViewColumnGroup("Notes"));

            cgv.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
            cgv.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
            cgv.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
            cgv.ColumnGroups[2].Rows.Add(new GridViewColumnGroupRow());
            cgv.ColumnGroups[2].Rows.Add(new GridViewColumnGroupRow());

            cgv.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Photo"]);
            cgv.ColumnGroups[0].ShowHeader = false;

            cgv.ColumnGroups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Title"]);
            cgv.ColumnGroups[1].Rows[1].Columns.Add(this.radGridView1.Columns["FirstName"]);
            cgv.ColumnGroups[1].Rows[1].Columns.Add(this.radGridView1.Columns["LastName"]);

            cgv.ColumnGroups[2].Rows[0].Columns.Add(this.radGridView1.Columns["City"]);
            cgv.ColumnGroups[2].Rows[0].Columns.Add(this.radGridView1.Columns["Country"]);
            cgv.ColumnGroups[2].Rows[0].Columns.Add(this.radGridView1.Columns["HomePhone"]);
            cgv.ColumnGroups[2].Rows[1].Columns.Add(this.radGridView1.Columns["Address"]);

            cgv.ColumnGroups[3].Rows.Add(new GridViewColumnGroupRow());
            cgv.ColumnGroups[3].Rows[0].Columns.Add(this.radGridView1.Columns["Notes"]);
            cgv.ColumnGroups[3].ShowHeader = false;

            // html view
            htmlViewInfo = new ViewDefinitionInfo();
            htmlViewInfo.ViewDefinition = new HtmlViewDefinition();
            htmlViewInfo.Columns        = new List <string>()
            {
                "Photo", "Title", "FirstName", "LastName", "City", "Country", "Address", "Phone", "BirthDate", "HireDate", "HomePhone"
            };

            HtmlViewDefinition htmlView = new HtmlViewDefinition();

            htmlView.RowTemplate.Rows.Add(new RowDefinition());
            htmlView.RowTemplate.Rows.Add(new RowDefinition());
            htmlView.RowTemplate.Rows.Add(new RowDefinition());
            htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Photo", 0, 1, 3));
            htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("FirstName", 0, 1, 1));
            htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("LastName", 0, 2, 1));
            htmlView.RowTemplate.Rows[0].Cells.Add(new CellDefinition("BirthDate", 0, 1, 1));
            htmlView.RowTemplate.Rows[1].Cells.Add(new CellDefinition("Title", 0, 3, 1));
            htmlView.RowTemplate.Rows[1].Cells.Add(new CellDefinition("HireDate", 0, 1, 1));
            htmlView.RowTemplate.Rows[2].Cells.Add(new CellDefinition("Address", 0, 1, 1));
            htmlView.RowTemplate.Rows[2].Cells.Add(new CellDefinition("City", 0, 1, 1));
            htmlView.RowTemplate.Rows[2].Cells.Add(new CellDefinition("Country", 0, 1, 1));
            htmlView.RowTemplate.Rows[2].Cells.Add(new CellDefinition("HomePhone", 0, 1, 1));
            htmlView.RowTemplate.Rows[0].Height = 23;
            htmlView.RowTemplate.Rows[1].Height = 23;
            htmlView.RowTemplate.Rows[2].Height = 32;

            htmlViewInfo.RowHeight      = -1;
            htmlViewInfo.HeaderHeight   = -1;
            htmlViewInfo.ViewDefinition = htmlView;
        }