Ejemplo n.º 1
0
        private static DataGridColumn CreateColumn(DataGrid gridView, object columnSource)
        {
            DgColumn col = columnSource as DgColumn;

            if (col.Control == "TextBlock")
            {
                DataGridTextColumn column = new DataGridTextColumn();
                column.Binding = new Binding(col.DisplayMember);
                return(column);
            }
            else if (col.Control == "PactComboBox")
            {
                DataGridPactComboBoxColumn column = new DataGridPactComboBoxColumn();
                column.Binding              = new Binding(col.DisplayMember);
                column.FeatureID            = Convert.ToInt32(col.Param);
                column.SelectedValueBinding = new Binding(col.DisplayMember + "_Key");
                return(column);
            }
            else if (col.Control == "DatePicker")
            {
                DataGridDateColumn column = new DataGridDateColumn();
                column.Binding = new Binding(col.DisplayMember);
                // column.SelectedValueBinding = new Binding(col.DisplayMember + "_Key");
                return(column);
            }
            else//if (col.ColumnType == "TextBox")
            {
                DataGridTextColumn column = new DataGridTextColumn();
                column.Binding = new Binding(col.DisplayMember);
                return(column);
            }
            //if (col.ColumnType == "MultiCombo")
            //{
            //    CustDataGridComboBoxColumn combcolumn = new CustDataGridComboBoxColumn();
            //    combcolumn.Header = col.HeaderText;
            //    combcolumn.DisplayMemberPath = col.DisplayMember;
            //    combcolumn.SelectedValuePath = col.ValueMember;
            //    combcolumn.SelectedValueBinding = new Binding(col.ValueBinding);

            //    combcolumn.ItemsSource = col.Source;
            //    combcolumn.Width = col.width;

            //    for (int i = 0; i < col.Columns.Count; i++)
            //    {
            //        GridViewColumn e = new GridViewColumn();
            //        e.Header = col.Columns[i].HeaderText;
            //        e.DisplayMemberBinding = new Binding(col.Columns[i].DisplayMember);
            //        combcolumn.Columns.Add(e);
            //    }

            //    return combcolumn;

            //}

            return(null);
        }
Ejemplo n.º 2
0
 private static void CreateColumns(Microsoft.Windows.Controls.DataGrid gridView, ICollectionView view)
 {
     foreach (var item in view)
     {
         DgColumn       obj    = item as DgColumn;
         DataGridColumn column = CreateColumn(gridView, item);
         column.IsReadOnly = obj.ReadOnly;
         column.Width      = obj.Width;
         column.DisableTab = obj.DisableTab;
         column.Header     = obj.Header;
         gridView.Columns.Add(column);
     }
 }