当前位置: 首页>>代码示例>>C#>>正文


C# DatePicker.SetValue方法代码示例

本文整理汇总了C#中System.Windows.Controls.DatePicker.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DatePicker.SetValue方法的具体用法?C# DatePicker.SetValue怎么用?C# DatePicker.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.DatePicker的用法示例。


在下文中一共展示了DatePicker.SetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeControl

        //Sets up the controls for the custom control
        private void InitializeControl()
        {
            int i = 0;

            foreach (CCustomLine cl in this.CustomFields.CustomLines)
            {
                //Add new row to the grid
                RowDefinition rd = new RowDefinition();
                rd.MinHeight = 30;
                rd.MaxHeight = 30;
                ControlGrid.RowDefinitions.Add(rd);

                System.Windows.Controls.TextBlock tb = new TextBlock();
                tb.SetValue(Grid.RowProperty, i);
                tb.SetValue(Grid.ColumnProperty, 0);
                tb.TextAlignment = TextAlignment.Right;
                tb.Margin = new Thickness(3);
                tb.Text = cl.Caption;
                ControlGrid.Children.Add(tb);

                 switch (cl.DataType)
                {
                    case CCustomLine.CustDataType.cdText:

                        if (cl.IsList)
                        {
                            System.Windows.Controls.ComboBox cbx = new ComboBox();
                            cbx.SetValue(Grid.RowProperty, i);
                            cbx.SetValue(Grid.ColumnProperty, 1);
                            cbx.Margin = new Thickness(3);
                            cbx.Tag = cl.Caption;
                            cbx.SelectionChanged += CustomDataChanged;

                            foreach (string sl in cl.PickList)
                            {
                                cbx.Items.Add(sl);
                            }
                            ControlGrid.Children.Add(cbx);
                        }
                        else
                        {
                            System.Windows.Controls.TextBox tbx = new TextBox();
                            tbx.SetValue(Grid.RowProperty, i);
                            tbx.SetValue(Grid.ColumnProperty, 1);
                            tbx.Margin = new Thickness(3);
                            tbx.Tag = cl.Caption;
                            tbx.Text = cl.Caption;
                            tbx.TextChanged += CustomDataChanged;
                            ControlGrid.Children.Add(tbx);
                        }
                        break;

                    case CCustomLine.CustDataType.cdDate:

                        System.Windows.Controls.DatePicker dtp = new DatePicker();
                        dtp.SetValue(Grid.RowProperty, i);
                        dtp.SetValue(Grid.ColumnProperty, 1);
                        dtp.Margin = new Thickness(3);
                        dtp.Tag = cl.Caption;
                        dtp.SelectedDateChanged += CustomDataChanged;
                        ControlGrid.Children.Add(dtp);
                        break;

                    case CCustomLine.CustDataType.cdInteger:

                        Xceed.Wpf.Toolkit.IntegerUpDown iud = new IntegerUpDown();
                        iud.SetValue(Grid.RowProperty, i);
                        iud.SetValue(Grid.ColumnProperty, 1);
                        iud.Margin = new Thickness(3);
                        iud.Tag = cl.Caption;
                        iud.ValueChanged += CustomDataChanged;
                        ControlGrid.Children.Add(iud);
                        break;

                    case CCustomLine.CustDataType.cdNumber:

                        Xceed.Wpf.Toolkit.CalculatorUpDown dud = new CalculatorUpDown();
                        dud.SetValue(Grid.RowProperty, i);
                        dud.SetValue(Grid.ColumnProperty, 1);
                        dud.Margin = new Thickness(3);
                        dud.Tag = cl.Caption;
                        dud.ValueChanged += CustomDataChanged;
                        ControlGrid.Children.Add(dud);
                        break;

                    case CCustomLine.CustDataType.cdCurrency:

                        Xceed.Wpf.Toolkit.CalculatorUpDown cud = new CalculatorUpDown();
                        cud.SetValue(Grid.RowProperty, i);
                        cud.SetValue(Grid.ColumnProperty, 1);
                        cud.Margin = new Thickness(3);
                        cud.Tag = cl.Caption;
                        cud.FormatString = "C2";
                        cud.ValueChanged += CustomDataChanged;
                        ControlGrid.Children.Add(cud);
                        break;

                    case CCustomLine.CustDataType.cdBoolean:

//.........这里部分代码省略.........
开发者ID:GeoffEngelstein,项目名称:WW6-WPF,代码行数:101,代码来源:CustomFieldEntry.xaml.cs


注:本文中的System.Windows.Controls.DatePicker.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。