コード例 #1
0
 private void grid_AutoGeneratingColumn(object sender, C1.WPF.DataGrid.DataGridAutoGeneratingColumnEventArgs e)
 {
     if (e.Property.Name == "Description")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "ID")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "Name")
     {
         e.Column = new DataGridMultiLineTextColumn(e.Property);
         e.Column.Header = "Multi-line column";
         e.Column.VerticalAlignment = VerticalAlignment.Top;
     }
     if (e.Property.Name == "ImageUrl")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "ProductSubcategoryID")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "Available")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "ExpirationDate")
     {
         e.Cancel = true;
         //e.Column.Format = "MM/dd/yy HH:mm:ss";
         //(e.Column as DataGridDateTimeColumn).DateFormat =
         //(e.Column as DataGridDateTimeColumn).TimeFormat = C1TimeEditorFormat.ShortTime;
     }
     if (e.Property.Name == "StandardCost")
     {
         e.Column = new DataGridCustomNumericColumn(e.Property);
         TextBlock _txtBlock = new TextBlock()
         {
             Text = "Std. Cost (tooltip)",
             HorizontalAlignment = HorizontalAlignment.Right,
             VerticalAlignment = VerticalAlignment.Center
         };
         ToolTipService.SetToolTip(_txtBlock, new ToolTip() { Content = "It's a custom tooltip." });
         e.Column.Header = _txtBlock;
     }
     if (e.Property.Name == "ProductNumber")
     {
         var column = new DataGridMaskedTextColumn(e.Property);
         column.Mask = "aa-aaaa-aa";
         column.TextMaskFormat = MaskFormat.IncludeLiterals;
         e.Column = column;
     }
     if (e.Property.Name == "ProductModelID")
     {
         var comboCol = new C1.WPF.DataGrid.DataGridComboBoxColumn(e.Property);
         comboCol.DisplayMemberPath = "Name";
         comboCol.SelectedValuePath = "ProductModelID";
         comboCol.ItemsSource = Data.GetModels();
         e.Column = comboCol;
     }
     if (e.Property.Name == "Color")
     {
         e.Column = new DataGridColorColumn(e.Property);
     }
 }
コード例 #2
0
 private void grid_AutoGeneratingColumn(object sender, C1.WPF.DataGrid.DataGridAutoGeneratingColumnEventArgs e)
 {
     if (e.Property.Name == "Description")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "ID")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "Name")
     {
         e.Column                   = new DataGridMultiLineTextColumn(e.Property);
         e.Column.Header            = "Multi-line column";
         e.Column.VerticalAlignment = VerticalAlignment.Top;
     }
     if (e.Property.Name == "ImageUrl")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "ProductSubcategoryID")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "Available")
     {
         e.Cancel = true;
     }
     if (e.Property.Name == "ExpirationDate")
     {
         e.Cancel = true;
         //e.Column.Format = "MM/dd/yy HH:mm:ss";
         //(e.Column as DataGridDateTimeColumn).DateFormat =
         //(e.Column as DataGridDateTimeColumn).TimeFormat = C1TimeEditorFormat.ShortTime;
     }
     if (e.Property.Name == "StandardCost")
     {
         e.Column = new DataGridCustomNumericColumn(e.Property);
         TextBlock _txtBlock = new TextBlock()
         {
             Text = "Std. Cost (tooltip)",
             HorizontalAlignment = HorizontalAlignment.Right,
             VerticalAlignment   = VerticalAlignment.Center
         };
         ToolTipService.SetToolTip(_txtBlock, new ToolTip()
         {
             Content = "It's a custom tooltip."
         });
         e.Column.Header = _txtBlock;
     }
     if (e.Property.Name == "ProductNumber")
     {
         var column = new DataGridMaskedTextColumn(e.Property);
         column.Mask           = "aa-aaaa-aa";
         column.TextMaskFormat = MaskFormat.IncludeLiterals;
         e.Column = column;
     }
     if (e.Property.Name == "ProductModelID")
     {
         var comboCol = new C1.WPF.DataGrid.DataGridComboBoxColumn(e.Property);
         comboCol.DisplayMemberPath = "Name";
         comboCol.SelectedValuePath = "ProductModelID";
         comboCol.ItemsSource       = Data.GetModels();
         e.Column = comboCol;
     }
     if (e.Property.Name == "Color")
     {
         e.Column = new DataGridColorColumn(e.Property);
     }
 }