Ejemplo n.º 1
0
        public static GridViewDataColumn GenerateGridviewColumn(string fieldName, string header, bool readOnly, int width, GridViewColumnType columnType)
        {
            var columnw = new GridViewHyperlinkColumn();

            GridViewDataColumn column = null;

            if (columnType == GridViewColumnType.Text)
            {
                column = new GridViewTextBoxColumn();
            }
            else if (columnType == GridViewColumnType.Numeric)
            {
                column = new GridViewTextBoxColumn();
            }
            else if (columnType == GridViewColumnType.CheckBox)
            {
                column = new GridViewCheckBoxColumn();
                (column as GridViewCheckBoxColumn).ThreeState = true;
            }
            else if (columnType == GridViewColumnType.Command)
            {
                column = new GridViewCommandColumn();
            }
            else if (columnType == GridViewColumnType.Link)
            {
                column = new GridViewHyperlinkColumn();
            }
            column.Name       = fieldName;
            column.FieldName  = fieldName;
            column.HeaderText = header;
            column.ReadOnly   = readOnly;
            column.Width      = width;
            return(column);
        }
        public static GridViewBoundColumnBase GenerateGridviewColumn(string fieldName, string header, bool readOnly, int?width, GridViewColumnType columnType, IEnumerable itemsSource = null)
        {
            var columnw = new GridViewHyperlinkColumn();

            GridViewBoundColumnBase column = null;

            if (columnType == GridViewColumnType.Text)
            {
                column = new GridViewDataColumn();
            }
            else if (columnType == GridViewColumnType.Numeric)
            {
                column = new GridViewDataColumn();
                //column = new GridViewMaskedInputColumn();
                //(column as GridViewMaskedInputColumn).MaskType = MaskType.Numeric;
            }
            else if (columnType == GridViewColumnType.CheckBox)
            {
                column = new GridViewCheckBoxColumn();
                (column as GridViewCheckBoxColumn).IsThreeState = true;
            }
            else if (columnType == GridViewColumnType.Command)
            {
                // column = new GridViewCommandColumn();
            }
            else if (columnType == GridViewColumnType.Link)
            {
                column = new GridViewHyperlinkColumn();
            }
            else if (columnType == GridViewColumnType.Color)
            {
                column = new MyColorPickerColumn();
            }
            else if (columnType == GridViewColumnType.Enum)
            {
                column = new GridViewComboBoxColumn();
                (column as GridViewComboBoxColumn).ItemsSource = itemsSource;
            }
            else if (columnType == GridViewColumnType.ComboBox)
            {
                column = new GridViewComboBoxColumn();

                (column as GridViewComboBoxColumn).ItemsSource = itemsSource;
            }
            //column.Name = fieldName;
            //column.TextAlignment = System.Windows.TextAlignment.Center;
            column.UniqueName        = fieldName;
            column.DataMemberBinding = new System.Windows.Data.Binding(fieldName);
            column.Header            = header;
            column.IsReadOnly        = readOnly;
            if (width != null)
            {
                column.Width = width.Value;
            }
            return(column);
        }
Ejemplo n.º 3
0
        private void InitGrid()
        {
            this.radGridView1.MasterTemplate.AllowAddNewRow      = false;
            this.radGridView1.MasterTemplate.AutoGenerateColumns = false;
            this.radGridView1.MasterTemplate.EnableFiltering     = true;
            this.radGridView1.MasterTemplate.EnableSorting       = true;
            this.radGridView1.MasterTemplate.EnableGrouping      = true;
            this.radGridView1.DataSource = null;
            this.radGridView1.MasterTemplate.Columns.Clear();

            var imageColumn = new GridViewImageColumn("image", "image");

            imageColumn.HeaderText  = "Image";
            imageColumn.ImageLayout = ImageLayout.Zoom;
            imageColumn.Width       = 150;
            this.radGridView1.MasterTemplate.Columns.Add(imageColumn);

            var asinColumn = new GridViewTextBoxColumn("external_product_id", "external_product_id");

            asinColumn.HeaderText = "ASIN";

            this.radGridView1.MasterTemplate.Columns.Add(asinColumn);
            this.radGridView1.MasterTemplate.Columns.Add("item_name", "Name", "item_name");
            this.radGridView1.MasterTemplate.Columns.Add("price", "Price", "price");

            var priceColumn = new GridViewDecimalColumn("real_price", "real_price");

            priceColumn.HeaderText = "real_price";
            this.radGridView1.MasterTemplate.Columns.Add(priceColumn);

            this.radGridView1.MasterTemplate.Columns.Add("Dimensions", "Dimensions", "Dimensions");
            this.radGridView1.MasterTemplate.Columns.Add("Size", "Size", "Size");
            this.radGridView1.MasterTemplate.Columns.Add("brand_name", "Brand", "brand_name");
            this.radGridView1.MasterTemplate.Columns.Add("product_type_name", "Type", "product_type_name");
            this.radGridView1.MasterTemplate.Columns.Add("department_name", "Department", "department_name");

            var urlColumn = new GridViewHyperlinkColumn("Url", "Url");

            urlColumn.HeaderText = "Url";
            this.radGridView1.MasterTemplate.Columns.Add(urlColumn);

            for (int i = 1; i < radGridView1.MasterTemplate.Columns.Count; i++)
            {
                this.radGridView1.MasterTemplate.Columns[i].Width = 120;
            }
            this.radGridView1.DataSource = _products;
        }
        public static GridViewBoundColumnBase GenerateGridviewColumn(string fieldName, string header, bool readOnly, int width, GridViewColumnType columnType)
        {
            var columnw = new GridViewHyperlinkColumn();

            GridViewBoundColumnBase column = null;

            if (columnType == GridViewColumnType.Text)
            {
                column = new GridViewDataColumn();
            }
            else if (columnType == GridViewColumnType.Numeric)
            {
                column = new GridViewDataColumn();
            }
            else if (columnType == GridViewColumnType.CheckBox)
            {
                column = new GridViewCheckBoxColumn();
                (column as GridViewCheckBoxColumn).IsThreeState = true;
            }
            else if (columnType == GridViewColumnType.Command)
            {
                // column = new GridViewCommandColumn();
            }
            else if (columnType == GridViewColumnType.Link)
            {
                column = new GridViewHyperlinkColumn();
            }
            //column.Name = fieldName;
            //column.TextAlignment = System.Windows.TextAlignment.Center;

            column.DataMemberBinding = new System.Windows.Data.Binding(fieldName);
            column.Header            = header;
            column.IsReadOnly        = readOnly;
            column.Width             = width;
            return(column);
        }
Ejemplo n.º 5
0
        private void BindGrid()
        {
            this.employeesTableAdapter.Fill(this.nwindDataSet.Employees);
            this.radGridView1.MasterTemplate.AutoGenerateColumns = false;
            radGridView1.DataSource = this.nwindDataSet.Employees;

            GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn();

            decimalColumn.FieldName     = "EmployeeID";
            decimalColumn.Name          = "EmployeeID";
            decimalColumn.HeaderText    = "Decimal";
            decimalColumn.DecimalPlaces = 0;
            decimalColumn.Width         = 100;
            decimalColumn.IsVisible     = false;
            this.radGridView1.Columns.Add(decimalColumn);

            GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn();

            textBoxColumn.FieldName  = "LastName";
            textBoxColumn.Name       = "LastName";
            textBoxColumn.HeaderText = "Text";
            textBoxColumn.Width      = 100;
            textBoxColumn.IsVisible  = false;
            this.radGridView1.Columns.Add(textBoxColumn);

            GridViewImageColumn imageColumn = new GridViewImageColumn();

            imageColumn.FieldName   = "Photo";
            imageColumn.Name        = "Photo";
            imageColumn.HeaderText  = "Image";
            imageColumn.ImageLayout = ImageLayout.Zoom;
            imageColumn.Width       = 54;
            this.radGridView1.Columns.Add(imageColumn);

            GridViewComboBoxColumn lookUpColumn = new GridViewComboBoxColumn();

            lookUpColumn.FieldName  = "TitleOfCourtesy";
            lookUpColumn.Name       = "LookUp";
            lookUpColumn.HeaderText = "LookUp";
            lookUpColumn.DataSource = new string[] { "Mr.", "Mrs.", "Dr.", "Ms." };
            lookUpColumn.Width      = 100;
            lookUpColumn.IsVisible  = false;
            this.radGridView1.Columns.Add(lookUpColumn);

            GridViewMaskBoxColumn maskBoxColumn = new GridViewMaskBoxColumn();

            maskBoxColumn.FieldName  = "HomePhone";
            maskBoxColumn.Name       = "MaskBox";
            maskBoxColumn.HeaderText = "MaskBox";
            maskBoxColumn.MaskType   = MaskType.Standard;
            maskBoxColumn.Mask       = "(###) ###-####";
            maskBoxColumn.Width      = 200;
            maskBoxColumn.IsVisible  = false;
            this.radGridView1.Columns.Add(maskBoxColumn);

            GridViewHyperlinkColumn hyperlinkColumn = new GridViewHyperlinkColumn("Hyperlink");

            hyperlinkColumn.ReadOnly = true;
            hyperlinkColumn.Width    = 200;
            this.radGridView1.Columns.Add(hyperlinkColumn);

            GridViewColorColumn colorColumn = new GridViewColorColumn("Color");

            colorColumn.Width = 100;
            this.radGridView1.Columns.Add(colorColumn);

            GridViewCalculatorColumn calculatorColumn = new GridViewCalculatorColumn("Calculator");

            calculatorColumn.Width = 80;
            this.radGridView1.Columns.Add(calculatorColumn);

            GridViewBrowseColumn browseColumn = new GridViewBrowseColumn("Browse");

            browseColumn.Width = 180;
            this.radGridView1.Columns.Add(browseColumn);

            GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn();

            checkBoxColumn.HeaderText = "CheckBox";
            checkBoxColumn.Name       = "CheckBox";
            checkBoxColumn.Width      = 100;
            checkBoxColumn.IsVisible  = false;
            this.radGridView1.Columns.Add(checkBoxColumn);

            GridViewDataColumn commandColumn = new GridViewTextBoxColumn();

            commandColumn.HeaderText = "Custom";
            commandColumn.Name       = "ProgressBar";
            commandColumn.DataType   = typeof(int);
            commandColumn.ReadOnly   = true;
            commandColumn.Width      = 100;
            this.radGridView1.Columns.Add(commandColumn);

            this.PopulateUnboundColumns();
        }