private void gridControl1_AutoGeneratingColumn(object sender, C1.WPF.DataGrid.DataGridAutoGeneratingColumnEventArgs e)
        {

            e.Column.EditOnSelection = true;//one click edit mode.
            //DS.Variables // list of all vars
            //if variable is of nominal type (ordinal is also nominal), then create new List of level names and store them on
            // that col
            foreach (DataSourceVariable dsv in DS.Variables)
            {
                if ((dsv.Name == e.Property.Name) && (dsv.Measure != DataColumnMeasureEnum.Scale) && (dsv.DataType != DataColumnTypeEnum.Character))//Character condition added on 02Jul2015 So character data will be treated as Nominal in grid but in R they are not factor type.
                {

                    List<string> droplst = dsv.Values;
                    ///09Oct2013 We may not need '.'. This topic is under discussion.
                    if (!droplst.Contains("<NA>"))
                        droplst.Add("<NA>");

                    var comboCol = new C1.WPF.DataGrid.DataGridComboBoxColumn(e.Property);
                    //comboCol.DisplayMemberPath =  "Name";
                    //comboCol.SelectedValuePath = "ProductModelID";
                    comboCol.ItemsSource = droplst;
                    comboCol.EditOnSelection = true;
                   // comboCol.Name = e.Property.Name;
                    //comboCol.SelectedValuePath = droplst.ElementAt(0);
                    e.Column = comboCol;
                    e.Cancel = false; 
                }

                ////  Creating column header with sort icon  ////10Apr2014
                StackPanel colheaderpanel = new StackPanel();
                colheaderpanel.Orientation = Orientation.Horizontal;

                //putting text before sort icon
                TextBlock txb = new TextBlock();
                //19Sep2014 txb.Text = e.Property.Name;
                txb.Text = GetRVarName(e.Property.Name);//19Sep2014 support R valid chars(in C# they are invalid)
                txb.Margin = new Thickness(2);

                /// Putting Sort icon in each column header
                Image sortico = new Image(); //b.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(b_MouseLeftButtonUp);
                sortico.ToolTip = "Sorted"; sortico.Height = 16.0; sortico.Width = 22.0; sortico.Margin = new Thickness(2);
                string packUri = null;
                if(sortorder!=null && sortorder.Equals("asc"))
                    packUri = "pack://application:,,,/BlueSky;component/Images/angle-arrow-up.png";
                else if (sortorder != null && sortorder.Equals("desc"))
                    packUri = "pack://application:,,,/BlueSky;component/Images/angle-arrow-down.png";
                else
                    packUri = "pack://application:,,,/BlueSky;component/Images/sorted_check.png";//default, not needed. Null exception if not used. fix later.

                sortico.Source = new ImageSourceConverter().ConvertFromString(packUri) as ImageSource;
                
                if(sortcolnames ==null || !sortcolnames.Contains(e.Property.Name)) // dont show sort icon on other columns
                sortico.Visibility = System.Windows.Visibility.Collapsed;

                colheaderpanel.Children.Add(txb);
                colheaderpanel.Children.Add(sortico);

                e.Column.Header = colheaderpanel;
                
            }
            
            //// Defining Style for Col-Header to have sort icon ///
            //Style st = new Style(typeof(DataGridColumnHeaderPresenter));
            //st.Setters.Add(new Setter() { Property = TabItem.BackgroundProperty, Value = Brushes.DarkGray });

            //Trigger tg = new Trigger { Property = TabItem.IsSelectedProperty, Value = true };
            //tg.Setters.Add(new Setter() { Property = TabItem.BackgroundProperty, Value = Brushes.Red });

            //st.Triggers.Add(tg);
            //e.Column.HeaderStyle = st;
        }
 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);
     }
 }
Пример #3
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);
     }
 }