/// <summary>
        /// Handles the AutoGeneratingColumn event of the Grid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataGridAutoGeneratingColumnEventArgs"/> instance containing the event data.</param>
        private void Grid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            if (e.Column.Header.ToString() == "תעודת זהות" || e.Column.Header.ToString() == "שם פרטי" || e.Column.Header.ToString() == "שם משפחה" || e.Column.Header.ToString() == "התחברות אחרונה ממחשב")
            {
                // e.Cancel = true;   // For not to include
                 e.Column.IsReadOnly = true; // Makes the column as read only
            }

            if (e.Column.Header.ToString() == "התחברות אחרונה")
             {
                (e.Column as DataGridTextColumn).Binding.StringFormat = "HH:mm:ss - dd/MM/yyyy";
                e.Column.IsReadOnly = true; // Makes the column as read only
             }

            if (e.Column.Header.ToString() == "תפקיד")
            {

                string columnName = e.Column.Header.ToString();
                Dictionary<string, string> comboKey = new Dictionary<string, string>()
                    {
                        {"מנהל","מנהל"},
                        {"מזכירה","מזכירה"},
                        {"איכות","איכות"},

                    };
                DataGridTemplateColumn col1 = new DataGridTemplateColumn();
                col1.Header = columnName;
                col1.SortMemberPath = columnName;
                #region Editing
                FrameworkElementFactory factory1 = new FrameworkElementFactory(typeof(ComboBox));
                Binding b1 = new Binding(columnName);
                b1.IsAsync = true;
                b1.Mode = BindingMode.TwoWay;
                factory1.SetValue(ComboBox.ItemsSourceProperty, comboKey);
                factory1.SetValue(ComboBox.SelectedValuePathProperty, "Key");
                factory1.SetValue(ComboBox.DisplayMemberPathProperty, "Value");
                factory1.SetValue(ComboBox.SelectedValueProperty, b1);
                factory1.SetValue(ComboBox.SelectedItemProperty, col1);

                DataTemplate cellTemplate1 = new DataTemplate();
                cellTemplate1.VisualTree = factory1;
                col1.CellTemplate = cellTemplate1;
                col1.CellEditingTemplate = cellTemplate1;
                col1.IsReadOnly = false;
                col1.InvalidateProperty(ComboBox.SelectedValueProperty);
                #endregion

                #region View
                FrameworkElementFactory sfactory = new FrameworkElementFactory(typeof(TextBlock));
                sfactory.SetValue(TextBlock.TextProperty, b1);
                DataTemplate cellTemplate = new DataTemplate();
                cellTemplate.VisualTree = sfactory;
                col1.CellTemplate = cellTemplate;
                #endregion

                e.Column = col1;
            }

            if (e.Column.Header.ToString() == "מחובר")
            {
                string columnName1 = e.Column.Header.ToString();
                Dictionary<string, string> comboKey1 = new Dictionary<string, string>()
                    {
                        {"מחובר","מחובר"},
                        {"לא מחובר","לא מחובר"},

                    };
                DataGridTemplateColumn col11 = new DataGridTemplateColumn();
                col11.Header = columnName1;
                col11.SortMemberPath = columnName1;
                #region Editing
                FrameworkElementFactory factory11 = new FrameworkElementFactory(typeof(ComboBox));
                Binding b11 = new Binding(columnName1);
                b11.IsAsync = true;
                b11.Mode = BindingMode.TwoWay;
                factory11.SetValue(ComboBox.ItemsSourceProperty, comboKey1);
                factory11.SetValue(ComboBox.SelectedValuePathProperty, "Key");
                factory11.SetValue(ComboBox.DisplayMemberPathProperty, "Value");
                factory11.SetValue(ComboBox.SelectedValueProperty, b11);
                factory11.SetValue(ComboBox.SelectedItemProperty, col11);

                DataTemplate cellTemplate1 = new DataTemplate();
                cellTemplate1.VisualTree = factory11;
                col11.CellTemplate = cellTemplate1;
                col11.CellEditingTemplate = cellTemplate1;
                col11.IsReadOnly = false;
                col11.InvalidateProperty(ComboBox.SelectedValueProperty);
                #endregion

                #region View
                FrameworkElementFactory sfactory = new FrameworkElementFactory(typeof(TextBlock));
                sfactory.SetValue(TextBlock.TextProperty, b11);
                DataTemplate cellTemplate = new DataTemplate();
                cellTemplate.VisualTree = sfactory;
                col11.CellTemplate = cellTemplate;
                #endregion

                e.Column = col11;
            }
        }
        /// <summary>
        /// Handles the AutoGeneratingColumn event of the Grid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataGridAutoGeneratingColumnEventArgs"/> instance containing the event data.</param>
        private void Grid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            if (e.Column.Header.ToString() == "מקט פריט" || e.Column.Header.ToString() == "שם פריט" || e.Column.Header.ToString() == "כמות כוללת בפועל" || e.Column.Header.ToString() == "מספר שלב הקבוצה" || e.Column.Header.ToString() == "שם שלב הקבוצה" || e.Column.Header.ToString() == "תאור שלב הקבוצה" || e.Column.Header.ToString() == "תיאור פריט")
            {
                // e.Cancel = true;   // For not to include
                e.Column.IsReadOnly = true; // Makes the column as read only
            }

            if (e.Column.Header.ToString() == "סטטוס קבוצה")
            {
                string columnName = e.Column.Header.ToString();
                Dictionary<string, string> comboKey = new Dictionary<string, string>()
                    {
                        {"רישום","רישום"},
                        {"בעבודה","בעבודה"},
                        {"תיקון","תיקון"},
                        {"פסול","פסול"},
                        {"גמר ייצור","גמר ייצור"},
                        {"הסתיים","הסתיים"},
                    };
                DataGridTemplateColumn col1 = new DataGridTemplateColumn();
                col1.Header = columnName;
                col1.SortMemberPath = columnName;
                #region Editing
                FrameworkElementFactory factory1 = new FrameworkElementFactory(typeof(ComboBox));
                Binding b1 = new Binding(columnName);
                b1.IsAsync = true;
                b1.Mode = BindingMode.TwoWay;
                factory1.SetValue(ComboBox.ItemsSourceProperty, comboKey);
                factory1.SetValue(ComboBox.SelectedValuePathProperty, "Key");
                factory1.SetValue(ComboBox.DisplayMemberPathProperty, "Value");
                factory1.SetValue(ComboBox.SelectedValueProperty, b1);
                factory1.SetValue(ComboBox.SelectedItemProperty, col1);

                DataTemplate cellTemplate1 = new DataTemplate();
                cellTemplate1.VisualTree = factory1;
                col1.CellTemplate = cellTemplate1;
                col1.CellEditingTemplate = cellTemplate1;
                col1.IsReadOnly = false;
                col1.InvalidateProperty(ComboBox.SelectedValueProperty);
                #endregion

                #region View
                FrameworkElementFactory sfactory = new FrameworkElementFactory(typeof(TextBlock));
                sfactory.SetValue(TextBlock.TextProperty, b1);
                DataTemplate cellTemplate = new DataTemplate();
                cellTemplate.VisualTree = sfactory;
                col1.CellTemplate = cellTemplate;
                #endregion

                e.Column = col1;
            }
        }
示例#3
0
        /// <summary>
        /// Handles the AutoGeneratingColumn event of the Grid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataGridAutoGeneratingColumnEventArgs"/> instance containing the event data.</param>
        private void Grid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            if (e.Column.Header.ToString() == "חפ לקוח" || e.Column.Header.ToString() == "מספר עבודה" || e.Column.Header.ToString() == "מספר איש קשר" || e.Column.Header.ToString() == "שם איש קשר" || e.Column.Header.ToString() == "שם לקוח")
            {
                // e.Cancel = true;   // For not to include
                e.Column.IsReadOnly = true; // Makes the column as read onl
            }

            //if the Column is a date Column then show me only the date
            if (e.Column.Header.ToString() == "תאריך התחלה")
            {
                (e.Column as DataGridTextColumn).Binding.StringFormat = "dd/MM/yyyy";

                /*
                // Create a new template column.
                DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();
                templateColumn.CellTemplate = (DataTemplate)Resources["dueDateCellTemplate"];
                templateColumn.CellEditingTemplate = (DataTemplate)Resources["dueDateCellEditingTemplate"];
                e.Column = templateColumn;
                */

                DataGridTemplateColumn dgct = new DataGridTemplateColumn();
                dgct.Header = "תאריך התחלה";
                dgct.SortMemberPath = "תאריך התחלה";

                Binding b = new Binding("תאריך התחלה");
                b.StringFormat = "dd/MM/yyyy";

                #region Editing
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(DatePicker));
                factory.SetValue(DatePicker.SelectedDateProperty, b);
                DataTemplate cellEditingTemplate = new DataTemplate();
                cellEditingTemplate.VisualTree = factory;
                dgct.CellEditingTemplate = cellEditingTemplate;
                #endregion

                #region View
                FrameworkElementFactory sfactory = new FrameworkElementFactory(typeof(TextBlock));
                sfactory.SetValue(TextBlock.TextProperty, b);
                DataTemplate cellTemplate = new DataTemplate();
                cellTemplate.VisualTree = sfactory;
                dgct.CellTemplate = cellTemplate;
                #endregion
                e.Column = dgct;
            }

            if (e.Column.Header.ToString() == "תאריך רישום")
            {
                DataGridTemplateColumn dgct = new DataGridTemplateColumn();
                string colname = e.Column.Header.ToString();
                dgct.Header = colname;
                dgct.SortMemberPath = colname;
                Binding b = new Binding(colname);
                b.StringFormat = "dd/MM/yyyy";

                #region Editing
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(DatePicker));
                factory.SetValue(DatePicker.SelectedDateProperty, b);
                DataTemplate cellEditingTemplate = new DataTemplate();
                cellEditingTemplate.VisualTree = factory;
                dgct.CellEditingTemplate = cellEditingTemplate;
                #endregion

                #region View
                FrameworkElementFactory sfactory = new FrameworkElementFactory(typeof(TextBlock));
                sfactory.SetValue(TextBlock.TextProperty, b);
                DataTemplate cellTemplate = new DataTemplate();
                cellTemplate.VisualTree = sfactory;
                dgct.CellTemplate = cellTemplate;
                #endregion
                e.Column = dgct;
            }

            if (e.Column.Header.ToString() == "תאריך סיום משוער" )
            {
                DataGridTemplateColumn dgct = new DataGridTemplateColumn();
                dgct.Header = "תאריך סיום משוער";
                dgct.SortMemberPath = "תאריך סיום משוער";

                Binding b = new Binding("תאריך סיום משוער");
                b.StringFormat = "dd/MM/yyyy";

                #region Editing
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(DatePicker));
                factory.SetValue(DatePicker.SelectedDateProperty, b);
                DataTemplate cellEditingTemplate = new DataTemplate();
                cellEditingTemplate.VisualTree = factory;
                dgct.CellEditingTemplate = cellEditingTemplate;
                #endregion

                #region View
                FrameworkElementFactory sfactory = new FrameworkElementFactory(typeof(TextBlock));
                sfactory.SetValue(TextBlock.TextProperty, b);
                DataTemplate cellTemplate = new DataTemplate();
                cellTemplate.VisualTree = sfactory;
                dgct.CellTemplate = cellTemplate;
                #endregion
                e.Column = dgct;
            }

            if (e.Column.Header.ToString() == "תאריך סיום בפועל")
            {
                DataGridTemplateColumn dgct = new DataGridTemplateColumn();
                dgct.Header = "תאריך סיום בפועל";
                dgct.SortMemberPath = "תאריך סיום בפועל";

                Binding b = new Binding("תאריך סיום בפועל");
                b.StringFormat = "dd/MM/yyyy";

                #region Editing
                FrameworkElementFactory factory = new FrameworkElementFactory(typeof(DatePicker));
                factory.SetValue(DatePicker.SelectedDateProperty, b);
                DataTemplate cellEditingTemplate = new DataTemplate();
                cellEditingTemplate.VisualTree = factory;
                dgct.CellEditingTemplate = cellEditingTemplate;
                #endregion

                #region View
                FrameworkElementFactory sfactory = new FrameworkElementFactory(typeof(TextBlock));
                sfactory.SetValue(TextBlock.TextProperty, b);
                DataTemplate cellTemplate = new DataTemplate();
                cellTemplate.VisualTree = sfactory;
                dgct.CellTemplate = cellTemplate;
                #endregion
                e.Column = dgct;
            }

            if (e.Column.Header.ToString() == "סטטוס עבודה")
            {

                string columnName1 = e.Column.Header.ToString();
                Dictionary<string, string> comboKey1 = new Dictionary<string, string>()
                    {
                        {"נרשמה","נרשמה"},
                        {"בעבודה","בעבודה"},
                        {"מושהת","מושהת"},
                        {"בוטלה","בוטלה"},
                        {"הסתיימה","הסתיימה"},
                    };
                DataGridTemplateColumn col11 = new DataGridTemplateColumn();
                col11.Header = columnName1;
                col11.SortMemberPath = columnName1;

                #region Editing
                FrameworkElementFactory factory11 = new FrameworkElementFactory(typeof(ComboBox));
                Binding b11 = new Binding(columnName1);
                b11.IsAsync = true;
                b11.Mode = BindingMode.TwoWay;
                factory11.SetValue(ComboBox.ItemsSourceProperty, comboKey1);
                factory11.SetValue(ComboBox.SelectedValuePathProperty, "Key");
                factory11.SetValue(ComboBox.DisplayMemberPathProperty, "Value");
                factory11.SetValue(ComboBox.SelectedValueProperty, b11);
                factory11.SetValue(ComboBox.SelectedItemProperty, col11);

                DataTemplate cellTemplate1 = new DataTemplate();
                cellTemplate1.VisualTree = factory11;
                col11.CellTemplate = cellTemplate1;
                col11.CellEditingTemplate = cellTemplate1;
                col11.IsReadOnly = false;
                col11.InvalidateProperty(ComboBox.SelectedValueProperty);
                #endregion

                #region View
                FrameworkElementFactory sfactory = new FrameworkElementFactory(typeof(TextBlock));
                sfactory.SetValue(TextBlock.TextProperty, b11);
                DataTemplate cellTemplate = new DataTemplate();
                cellTemplate.VisualTree = sfactory;
                col11.CellTemplate = cellTemplate;
                #endregion

                e.Column = col11;

            }
        }