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


C# Controls.ComboBox类代码示例

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


ComboBox类属于System.Windows.Controls命名空间,在下文中一共展示了ComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GeneralRequestVisualizer

        public GeneralRequestVisualizer()
        {
            title = NameValuePanel.Create("Title", new TextBox());

            var url = NameValuePanel.Create("URL", new TextBox());
            var method = new ComboBox
            {
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(0, 0, 5, 0),
                SelectedIndex = 0
            };

            var urlAndMethod = new Grid();
            urlAndMethod.AddColumn(1, GridUnitType.Star);
            urlAndMethod.AddColumn(100, GridUnitType.Pixel);
            urlAndMethod.AddRow(GridLength.Auto);
            urlAndMethod.Add(url, 0, 0);
            urlAndMethod.Add(method, 0, 1);

            var apiGeneralStackPanel = new StackPanel
            {
                Margin = new Thickness(0, 0, 0, 10)
            };
            apiGeneralStackPanel.Children.Add(title);
            apiGeneralStackPanel.Children.Add(urlAndMethod);
            Children.Add(apiGeneralStackPanel);

            this.Bind(x => x.Model.Title).Mate(title.Value);
            this.Bind(x => x.Model.Url).Mate(url.Value);
            this.Bind(x => x.Model.Method).Mate(method, x => x.MainWindow.Methods);
        }
开发者ID:kswoll,项目名称:restless,代码行数:31,代码来源:GeneralRequestVisualizer.cs

示例2: MakeGivenGrid

        protected override Grid MakeGivenGrid()
        {
            //Set up grid
            Grid grid = new Grid();
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            //Create the description text
            TextBlock desc = new TextBlock();
            desc.TextWrapping = TextWrapping.Wrap;
            desc.Text = "Specify a midpoint.";
            desc.Margin = new Thickness(0, 0, 0, 10);

            //Create a combo box to choose from
            optionsBox = new ComboBox();
            optionsBox.MinWidth = 200;

            //Align elements in grid and add them to it
            Grid.SetColumn(desc, 0);
            Grid.SetRow(desc, 0);
            grid.Children.Add(desc);
            Grid.SetColumn(optionsBox, 0);
            Grid.SetRow(optionsBox, 1);
            grid.Children.Add(optionsBox);

            return grid;
        }
开发者ID:wcatykid,项目名称:GeoShader,代码行数:28,代码来源:AddMidpoint.cs

示例3: RegisterForm_AutoGeneratingField

        /// <summary>
        /// Wire up the Password and PasswordConfirmation accessors as the fields get generated.
        /// Also bind the Question field to a ComboBox full of security questions, and handle the LostFocus event for the UserName TextBox.
        /// </summary>
        private void RegisterForm_AutoGeneratingField(object dataForm, DataFormAutoGeneratingFieldEventArgs e)
        {
            // Put all the fields in adding mode
            e.Field.Mode = DataFieldMode.AddNew;

            if (e.PropertyName == "UserName")
            {
                this.userNameTextBox = (TextBox)e.Field.Content;
                this.userNameTextBox.LostFocus += this.UserNameLostFocus;
            }
            else if (e.PropertyName == "Password")
            {
                PasswordBox passwordBox = new PasswordBox();
                e.Field.ReplaceTextBox(passwordBox, PasswordBox.PasswordProperty);
                this.registrationData.PasswordAccessor = () => passwordBox.Password;
            }
            else if (e.PropertyName == "PasswordConfirmation")
            {
                PasswordBox passwordConfirmationBox = new PasswordBox();
                e.Field.ReplaceTextBox(passwordConfirmationBox, PasswordBox.PasswordProperty);
                this.registrationData.PasswordConfirmationAccessor = () => passwordConfirmationBox.Password;
            }
            else if (e.PropertyName == "Question")
            {
                ComboBox questionComboBox = new ComboBox();
                questionComboBox.ItemsSource = RegistrationForm.GetSecurityQuestions();
                e.Field.ReplaceTextBox(questionComboBox, ComboBox.SelectedItemProperty, binding => binding.Converter = new TargetNullValueConverter());
            }
        }
开发者ID:fr4nky80,项目名称:LearnCSharp,代码行数:33,代码来源:RegistrationForm.xaml.cs

示例4: AutoCompleteTextBox

        public AutoCompleteTextBox()
        {
            controls = new VisualCollection(this);
            InitializeComponent();

            searchThreshold = 2;        // default threshold to 2 char

            // set up the key press timer
            keypressTimer = new System.Timers.Timer();
            keypressTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);

            // set up the text box and the combo box
            comboBox = new ComboBox();
            comboBox.IsSynchronizedWithCurrentItem = true;
            comboBox.IsTabStop = false;
            comboBox.SelectionChanged += new SelectionChangedEventHandler(comboBox_SelectionChanged);

            textBox = new TextBox();
            textBox.TextChanged += new TextChangedEventHandler(textBox_TextChanged);
            textBox.VerticalContentAlignment = VerticalAlignment.Center;

            controls.Add(comboBox);
            controls.Add(textBox);

        }
开发者ID:TrinityCore-Manager,项目名称:TrinityCore-Manager-v3,代码行数:25,代码来源:AutoCompleteTextBox.xaml.cs

示例5: CreateComboBox

 protected virtual FrameworkElement CreateComboBox(PropertyItem pi, PropertyControlFactoryOptions options)
 {
     var cbox = new ComboBox() { IsEditable = true };
     cbox.SetBinding(Selector.SelectedItemProperty, new Binding(pi.Descriptor.Name + ".Text"));
     cbox.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(pi.Descriptor.Name + ".Values"));
     return cbox;
 }
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:7,代码来源:PropertyControlFactory.cs

示例6: QueryBySQL

        public QueryBySQL()
        {
            InitializeComponent();
            featuresLayer = MyMap.Layers[1] as FeaturesLayer;

            //设置显示查询图层的下拉框
            #region ComboBox
            comboBox = new ComboBox();
            comboBox.Width = 160;
            comboBox.Height = 25;
            comboBox.VerticalAlignment = VerticalAlignment.Top;
            comboBox.HorizontalAlignment = HorizontalAlignment.Right;

            ComboBoxItem itemPoint = new ComboBoxItem();
            itemPoint.Content = PointLayerName;
            ComboBoxItem itemLine = new ComboBoxItem();
            itemLine.Content = LineLayerName;
            ComboBoxItem itemRegion = new ComboBoxItem();
            itemRegion.Content = AreaLayerName;
            ComboBoxItem itemAll = new ComboBoxItem();
            itemAll.Content = "全部图层";
            comboBox.Items.Add(itemPoint);
            comboBox.Items.Add(itemLine);
            comboBox.Items.Add(itemRegion);
            comboBox.Items.Add(itemAll);
            MyStackPanel.Children.Add(comboBox);
            comboBox.SelectedIndex = 2;
            #endregion

            MyTextBox.Text = "smid<10 and smid>3";
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:31,代码来源:QueryBySQL.xaml.cs

示例7: VoucherTemplateSearch

 public VoucherTemplateSearch(ref TextBox textBox, ref ComboBox debitAccountComboBox, ref ComboBox creditAccountComboBox)
 {
     InitializeComponent();
     _shortCodeTextBox = textBox;
     _debitAccount = debitAccountComboBox;
     _creditAccount = creditAccountComboBox;
 }
开发者ID:juwelahmed,项目名称:OfficeFinancial,代码行数:7,代码来源:VoucherTemplateSearch.xaml.cs

示例8: CreateEditingElement

        protected override FrameworkElement CreateEditingElement()
        {
            this._cb = new ComboBox();
            this._cb.Name = this.Meta.Name;
            this._cb.SelectedValuePath = "EnumValue";
            this._cb.DisplayMemberPath = "TranslatedLabel";

            this.ResetBinding(this._cb);

            //cb.Items.Clear();
            var propertyType = this.Meta.PropertyMeta.Runtime.PropertyType;
            foreach (var item in EnumViewModel.GetByEnumType(propertyType))
            {
                this._cb.Items.Add(item);
            }
            if (TypeHelper.IsNullable(propertyType))
            {
                //这种组合下,不能随意录入值、可以选择文本、按上下键选择项。缺点是不能通过输入搜索项。
                this._cb.IsEditable = true;
                this._cb.IsReadOnly = true;
                this._cb.PreviewKeyDown += On_cb_PreviewKeyDown;
            }

            this.AddReadOnlyComponent(this._cb, ComboBox.IsEnabledProperty, false);

            this.SetAutomationElement(this._cb);

            this._cb.SelectionChanged += On_cb_SelectionChanged;
            this._cb.DropDownOpened += On_cb_DropDownOpened;
            this._cb.DataContextChanged += On_cb_DataContextChanged;

            return this._cb;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:33,代码来源:EnumPropertyEditor.cs

示例9: ComboBoxBackend

        public ComboBoxBackend()
        {
            Widget = new WindowsComboBox();

            ComboBox.ItemTemplate = Defaulttemplate;
            ComboBox.ItemContainerStyle = ContainerStyle;
        }
开发者ID:joncham,项目名称:xwt,代码行数:7,代码来源:ComboBoxBackend.cs

示例10: btnBuyAircraft_Click

        private void btnBuyAircraft_Click(object sender, RoutedEventArgs e)
        {
            ComboBox cbAircraft = new ComboBox();
            cbAircraft.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbAircraft.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbAircraft.ItemTemplate = this.Resources["TrainingAircraftTypeItem"] as DataTemplate;
            cbAircraft.Width = 300;

            foreach (TrainingAircraftType type in TrainingAircraftTypes.GetAircraftTypes().FindAll(t => GeneralHelpers.GetInflationPrice(t.Price) < GameObject.GetInstance().HumanAirline.Money))
                cbAircraft.Items.Add(type);

            cbAircraft.SelectedIndex = 0;

            if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageShowFlightSchool", "1014"), cbAircraft) == PopUpSingleElement.ButtonSelected.OK && cbAircraft.SelectedItem != null)
            {

                TrainingAircraftType aircraft = (TrainingAircraftType)cbAircraft.SelectedItem;
                double price = aircraft.Price;

                this.FlightSchool.addTrainingAircraft(new TrainingAircraft(aircraft, GameObject.GetInstance().GameTime, this.FlightSchool.FlightSchool));

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -price);

                setHireStudentsStatus();

            }
        }
开发者ID:tehknox,项目名称:tap-desktop,代码行数:27,代码来源:PageShowFlightSchool.xaml.cs

示例11: foreach

 public void cbx預設條件賦值(string browsetype, ComboBox cbx)
 {
     DataTable 自訂條件別 = 查詢LCL所在位置("LCL自訂條件別");
     if (browsetype == "" || browsetype == null)
     {
         權限表 qry = (from a in 使用者Bll.GetInstance().權限表
                            where a.程式名稱 == 程式名稱
                            select a).First();
         //DataRow[] dr權限 = 使用者Bll.GetInstance().權限表.Select("程式名稱 = '" + 程式名稱 + "'");
         //string 編號 = dr權限[0]["序號"].ToString();
         string 編號 = qry.序號;
         編號 = 編號.Substring(0, 編號.IndexOf("-")) + 編號.Substring(編號.IndexOf("-") + 1) + "B";
         cbx.ItemsSource = 自訂條件別.Select("編號 LIKE '%" + 編號 + "%'");
     }
     else
     {
         DataRow[] drs = 自訂條件別.Select("編號 LIKE '%" + browsetype + "%'");
         條件編號 = new List<string>();
         條件說明 = new List<string>();
         foreach (DataRow row in drs)
         {
             條件編號.Add(row["編號"].ToString());
             條件說明.Add(row["類別"].ToString());
         }
         cbx.DataContext = 條件編號;
     }
 }
开发者ID:momo16542,项目名称:DarbWareERP,代码行数:27,代码来源:瀏覽ViewModel.cs

示例12: populateSearchBarWithAllData

        //This section is used to populate search bar with the contents( Factory Name, Item Name and Description )
        public void populateSearchBarWithAllData(ComboBox cmbBox)
        {
            try
            {
                using (adoraDBContext a = new adoraDBContext())
                {
                    //retriving factory name, item name and description from the database and saving it in a list
                    var factoryName = (from e in a.StockInHands
                                       select new { e.FactoryName, e.ItemName, e.descript }
                   ).Distinct().ToList();

                    List<String> nList = new List<string>();

                    //pulling retrived data from the list and setting them in the combo box record
                    for (int i = 0; i < factoryName.Count; i++)
                    {
                        String n = factoryName[i].FactoryName.ToString();
                        String m = factoryName[i].ItemName.ToString();
                        String l = factoryName[i].descript.ToString();

                        String nm = n + "  ->  " + m + "  ->  " + l;
                        nList.Add(nm);
                    }

                    cmbBox.ItemsSource = nList;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
开发者ID:sankalpau3,项目名称:AdoraDestopAppFinalized,代码行数:33,代码来源:fobStockInHandDAO.cs

示例13: SetCoatingType

 public static void SetCoatingType(ComboBox item)
     {
         item.ItemsSource = ((IListSource)_setMaterials.CoatingTypeDt()).GetList();
         item.DisplayMemberPath = "Name";
         item.SelectedValuePath = "Code";
         item.SelectedIndex = 0;
     }
开发者ID:GitHubVents,项目名称:AirVentsCad,代码行数:7,代码来源:Totals.cs

示例14: SetMontageFrameMaterial

 public static void SetMontageFrameMaterial(ComboBox item)
 {
     item.ItemsSource = ((IListSource)SqlBaseData.MaterialsForMontageFrame()).GetList();
     item.DisplayMemberPath = "MaterialsName";
     item.SelectedValuePath = "LevelID";
     item.SelectedIndex = 0;
 }
开发者ID:GitHubVents,项目名称:AirVentsCad,代码行数:7,代码来源:Totals.cs

示例15: ProcessorFamily

            public ProcessorFamily(Panel parentPanel, int idx, string name)
            {
                Index = idx;
                Name = name;
                SelectedProcessor = null;

                LabelName = new Label();
                LabelName.Content = "Choose " + name;
                DockPanel.SetDock(LabelName, Dock.Top);
                LabelName.Height = 30.0;
                LabelName.HorizontalContentAlignment = HorizontalAlignment.Center;
                parentPanel.Children.Add(LabelName);

                ComboProcessors = new ComboBox();
                DockPanel.SetDock(ComboProcessors, Dock.Top);
                ComboProcessors.Height = 25.0;
                ComboProcessors.Margin = new Thickness(30.0, 5.0, 30.0, 5.0);
                ComboProcessors.HorizontalContentAlignment = HorizontalAlignment.Center;
                parentPanel.Children.Add(ComboProcessors);

                ComboProcessors.SelectionChanged += ComboProcessors_SelectionChanged;

                ParametersPanel = new ParametersSelectionPanel();
                ParametersPanel.MinHeight = 20.0;
                DockPanel.SetDock(ParametersPanel, Dock.Top);
                parentPanel.Children.Add(ParametersPanel);
            }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:27,代码来源:ParametrizedProcessorsSelectionPanel.xaml.cs


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