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


C# Controls.CheckBox类代码示例

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


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

示例1: AttachControl

        public override bool AttachControl(FilterPropertiesControl control)
        {
            Control = control;

            Grid grid = new Grid();
            int rowIndex = 0;

            CheckBox distinctEdgesCheckBox = new CheckBox();
            TextBlock textBlock = new TextBlock {Text = AppResources.DistinctEdges};
            distinctEdgesCheckBox.Content = textBlock;
            distinctEdgesCheckBox.IsChecked = _cartoonFilter.DistinctEdges;
            distinctEdgesCheckBox.Checked += distinctEdgesCheckBox_Checked;
            distinctEdgesCheckBox.Unchecked += distinctEdgesCheckBox_Unchecked;
            Grid.SetRow(distinctEdgesCheckBox, rowIndex++);

            for (int i = 0; i < rowIndex; ++i)
            {
                RowDefinition rd = new RowDefinition();
                grid.RowDefinitions.Add(rd);
            }

            grid.Children.Add(distinctEdgesCheckBox);

            control.ControlsContainer.Children.Add(grid);

            return true;
        }
开发者ID:KayNag,项目名称:LumiaImagingSDKSample,代码行数:27,代码来源:MarvelFilter.cs

示例2: AddCheckBox

        private static void AddCheckBox(int col, int row, string name, RoutedEventHandler onClickCheckBox)
        {
            var checkBox = new CheckBox();

            if (!string.IsNullOrEmpty(name))
            {
                checkBox.Name = name;
            }

            checkBox.Click += onClickCheckBox;
            checkBox.HorizontalAlignment = HorizontalAlignment.Center;
            checkBox.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(checkBox, row);
            Grid.SetColumn(checkBox, col);
            _grid.Children.Add(checkBox);

            try
            {
                _grid.RegisterName(checkBox.Name, checkBox);
            }
            catch (Exception)
            {
                // ignored
            }
        }
开发者ID:idan573,项目名称:projectArduinoFirstTry,代码行数:25,代码来源:RowAdder.cs

示例3: SelectContentForItems

 public SelectContentForItems()
 {
     InitializeComponent();
     LabelInfo.Content = "Select content for field " + Slicer.infoAboutSelectedFields[Slicer.amount][0];
     try
     {
         MainWindow.connection.Open();
         SqlCommand command = new SqlCommand("select distinct "+ Slicer.infoAboutSelectedFields[Slicer.amount][0] + " from ["+ Slicer.nameOfTable + "]", MainWindow.connection);
         SqlDataReader reader = command.ExecuteReader();
         Slicer.contentOfFields.Clear();
         while (reader.Read())
         {
             for (int i = 0; i < reader.FieldCount; i++)
             {
                 CheckBox item = new CheckBox();
                 item.Content = reader[i].ToString();
                 ListBoxContentForField.Items.Add(item);
                 Slicer.contentOfFields.Add(item);
             }
         }
     }
     catch (SqlException se)
     {
         MessageBox.Show(se.Message);
     }
     finally
     {
         MainWindow.connection.Close();
     }
 }
开发者ID:molochiy,项目名称:Education,代码行数:30,代码来源:SelectContentForItems.xaml.cs

示例4: LoadChecbox

 private void LoadChecbox(CheckBox chkbox, string p)
 {
     if (p == "False")
         chkbox.IsChecked = false;
     else
         chkbox.IsChecked = true;
 }
开发者ID:K1wi,项目名称:Rename,代码行数:7,代码来源:Window1.xaml.cs

示例5: GetGUIElement

        public override FrameworkElement GetGUIElement()
        {
            var group = new GroupBox();

            group.Header = WpfName;

            var stackPanel = new StackPanel { Orientation = Orientation.Horizontal };

            for (var i = 0; i < options.Length; ++i)
            {
                var checkBox = new CheckBox
                                 {
                                     Content = options[i],
                                     DataContext = i,
                                     IsChecked = chosenOptions.Contains(i)
                                 };
                checkBox.Margin = new Thickness(4, 3, 4, 3);
                checkBox.Checked += (sender, args) =>
                    { chosenOptions.Add((int)(sender as CheckBox).DataContext); };
                checkBox.Unchecked += (sender, args) =>
                    { chosenOptions.Remove((int)(sender as CheckBox).DataContext); };

                stackPanel.Children.Add(checkBox);
            }

            group.Content = stackPanel;

            return group;
        }
开发者ID:Art1stical,项目名称:AHRUnrealEngine,代码行数:29,代码来源:MultipleChoiceParam.cs

示例6: CreateCheckBox

        /// <summary>
        /// Creates a CheckBox for switch parameters
        /// </summary>
        /// <param name="parameterViewModel">DataContext object</param>
        /// <param name="rowNumber">Row number</param>
        /// <returns>a CheckBox for switch parameters</returns>
        private static CheckBox CreateCheckBox(ParameterViewModel parameterViewModel, int rowNumber)
        {
            CheckBox checkBox = new CheckBox();

            checkBox.SetBinding(Label.ContentProperty, new Binding("NameCheckLabel"));
            checkBox.DataContext = parameterViewModel;
            checkBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            checkBox.SetValue(Grid.ColumnProperty, 0);
            checkBox.SetValue(Grid.ColumnSpanProperty, 2);
            checkBox.SetValue(Grid.RowProperty, rowNumber);
            checkBox.IsThreeState = false;
            checkBox.Margin = new Thickness(8, rowNumber == 0 ? 7 : 5, 0, 5);
            checkBox.SetBinding(CheckBox.ToolTipProperty, new Binding("ToolTip"));
            Binding valueBinding = new Binding("Value");
            checkBox.SetBinding(CheckBox.IsCheckedProperty, valueBinding);

            //// Add AutomationProperties.AutomationId for Ui Automation test.
            checkBox.SetValue(
                System.Windows.Automation.AutomationProperties.AutomationIdProperty,
                string.Format(CultureInfo.CurrentCulture, "chk{0}", parameterViewModel.Name));

            checkBox.SetValue(
                System.Windows.Automation.AutomationProperties.NameProperty,
                parameterViewModel.Name);

            return checkBox;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:33,代码来源:ParameterSetControl.xaml.cs

示例7: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            rep = new Repository();
            List<Standard> standards = new List<Standard>();
            standards = rep.getStandards();
            foreach (Standard standard in standards)
            {
                comboStandardId.Items.Add(standard.StandardName);
            }

            CheckBox box;
            for (int i = 0; i < 10; i++)
            {
                box = new CheckBox();
               
                box.Tag = i.ToString();
                box.Text = "a";
                box.AutoSize = true;
                box.Location = new Point(10, i * 50); //vertical
                                                      //box.Location = new Point(i * 50, 10); //horizontal
                this.Controls.Add(box);
            }

        }
开发者ID:Maldercito,项目名称:adat,代码行数:25,代码来源:1453204634$MainWindow.xaml.cs

示例8: fillCheckboxList

        private void fillCheckboxList()
        {
            _skills.Clear();
            foreach (var item in SkillVM.Skills)
            {
                var cb = new CheckBox();
                cb.Content = item.Name;
                _skills.Add(cb);
                cb.IsChecked = false;
            }

            SkillsListBox.Items.Clear();
            foreach (var item in _skills)
            {
                SkillsListBox.Items.Add(item);
            }

            if (_projectModuleEditVM != null && _projectModuleEditVM.ProjectVM != null)
            {
                var selectedSkills = _projectModuleEditVM.Skills;
                foreach (var item in _skills)
                {
                    if (_savedSkills == null)
                        item.IsChecked = selectedSkills.FirstOrDefault(skill => skill == item.Content.ToString()) != null ? true : false;
                    else
                    {
                        var isExist = _savedSkills.FirstOrDefault(skill => skill.Content.ToString() == item.Content.ToString());
                        item.IsChecked = isExist == null ? false : isExist.IsChecked;
                    }
                }

                _savedSkills = null;
            }
        }
开发者ID:Vsailor,项目名称:ProjectManager,代码行数:34,代码来源:ProjectModuleEdit.xaml.cs

示例9: FillingScrData

        void FillingScrData()
        {
            List<Teacher> teacher = new List<Teacher>();
            chTeacher = new CheckBox[schedule.EStorage.Teachers.Count()];
            List<string> FIO = new List<string>();
            foreach (var item in schedule.EStorage.Teachers.ToList())
            {
                FIO.Add(item.Name);
            }
            FIO.Sort();
           
            foreach (var fio in FIO)
            {
                foreach (var item in schedule.EStorage.Teachers.ToList())
                {
                    if (item.Name == fio)
                    {
                        teacher.Remove(item);
                        teacher.Add(item);
                    }
                }
            }

            for (int indexchb = 0; indexchb < teacher.Count; indexchb++)
            {
                chTeacher[indexchb] = new CheckBox()
                {
                    Content = teacher[indexchb].Name,
                 
                };
                chTeacher[indexchb].Checked += checkBox_Checked;
                chTeacher[indexchb].Unchecked += checkBox_Unchecked;
            }
            scrData.ItemsSource = chTeacher;
        }
开发者ID:Eugenni,项目名称:mandarin,代码行数:35,代码来源:ScheduleTeacherExcelForm.xaml.cs

示例10: LoadNations

        void LoadNations()
        {
            int LanguageIndex = edtContentLang.SelectedIndex;
            spNations.Children.Clear();
            nations = MythDB.Instance.Database.Nations.ToList();
            checkBoxes = new List<CheckBox>();
            foreach (Nation n in nations)
            {
                StackPanel sp = new StackPanel();
                sp.Orientation = System.Windows.Controls.Orientation.Horizontal;
                sp.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                sp.VerticalAlignment = System.Windows.VerticalAlignment.Center;

                TextBlock tb = new TextBlock();
                tb.Text = "[" + n.I18nNations[LanguageIndex].ShortName + "] " + n.I18nNations[LanguageIndex].Name;
                tb.FontSize = 20;
                tb.Width = 350;
                tb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                sp.Children.Add(tb);

                CheckBox cb = new CheckBox();
                cb.IsChecked = n.IsActive;
                cb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                sp.Children.Add(cb);
                checkBoxes.Add(cb);

                spNations.Children.Add(sp);
            }
        }
开发者ID:bashlykevich,项目名称:MythologyWP,代码行数:29,代码来源:SettingsPage.xaml.cs

示例11: FillinfCheckBox

        public bool FillinfCheckBox(ref CheckBox[] ChB,ref CheckBox[] ChB1,ref int[] Mapping, string sqlcom, Grid grid)
        {
            try
            {
                SqlDataAdapter sqladapter = new SqlDataAdapter(sqlcom, connection);
                SqlCommandBuilder sqlcmd = new SqlCommandBuilder(sqladapter);
                DataTable dt = new DataTable();
                sqladapter.Fill(dt);
                ChB = new CheckBox[dt.Rows.Count];
                ChB1 = new CheckBox[dt.Rows.Count];
                Mapping = new int[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)//выставить по высоте
                {
                    ChB[i] = new CheckBox() { Content = dt.Rows[i][1].ToString() };
                    ChB[i].Margin = new Thickness(10, 15 + 20 * i, 0, 0);
                    ChB1[i] = new CheckBox() { Content = "" };
                    ChB1[i].Margin = new Thickness(220, 15 + 20 * i, 0, 0);
                    grid.Children.Add(ChB[i]);
                    grid.Children.Add(ChB1[i]);
                    Mapping[i] = Convert.ToInt32(dt.Rows[i][0].ToString());
                }
                return true;
            }
            catch
            {
                return false;
            }


        }
开发者ID:Ser95,项目名称:BDprogramm,代码行数:30,代码来源:ForWorkBD.cs

示例12: checkBox_Checked

        public void checkBox_Checked(object sender, RoutedEventArgs e)
        {
            
            CheckBox thisCheckBox = (CheckBox)sender;
            if (licznik == 0)
            {
                licznik++;
                lastCheckBox = (CheckBox)sender;
            }
            else
            {
                if (MessageBox.Show("Do you wish to keep these languages?\n" + lastCheckBox.Name + "\n" + thisCheckBox.Name, "Languages picked", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    Global.Jezyk1 = Convert.ToInt32(Global.LanguageNameToId(lastCheckBox.Name));
                    Global.Jezyk2 = Convert.ToInt32(Global.LanguageNameToId(thisCheckBox.Name));
                    NavigationService.Navigate(new Uri("/Tags.xaml", UriKind.Relative));

                }
                else
                {
                    licznik = 0;
                    lastCheckBox.IsChecked = false;
                    thisCheckBox.IsChecked = false;
                }
            }
        }
开发者ID:jnowicki,项目名称:WP-EduWords,代码行数:26,代码来源:Languages.xaml.cs

示例13: initialize

    protected override void initialize() {
      base.initialize();
      this.currentValue = this.Property.Value as Boolean?;
      this.Property.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.property_PropertyChanged);
      this.Property.ValueError += new EventHandler<ExceptionEventArgs>(this.property_ValueError);

      this.cbx = new CheckBox() {
        Visibility = Visibility.Visible,
        //Margin = new Thickness(1),
        VerticalAlignment = VerticalAlignment.Center,
        HorizontalAlignment = HorizontalAlignment.Left,
        VerticalContentAlignment = VerticalAlignment.Center,
        Margin = new Thickness(1, 4, 0, 0),
        IsChecked = this.currentValue,
        IsEnabled = this.Property.CanWrite,
        Cursor = Cursors.Hand
      };
      this.Content = this.cbx;
      this.cbx.Checked += new RoutedEventHandler(this.cbx_CheckboxChanged);
      this.cbx.Unchecked += new RoutedEventHandler(this.cbx_CheckboxChanged);
      //this.dtp.CalendarClosed += new RoutedEventHandler(dtp_CalendarClosed);
      //this.dtp.LostFocus += new RoutedEventHandler(dtp_LostFocus);
      //this.pnl.Children.Add(dtp);
      this.cbx.Focus();
    }
开发者ID:tormoz70,项目名称:Bio.Framework.8,代码行数:25,代码来源:BooleanValueEditor.cs

示例14: GetUIElement

        public override UIElement GetUIElement()
        {
            var grid = new Grid();

            ColumnDefinition columnDefinition1 = new ColumnDefinition();
            ColumnDefinition columnDefinition2 = new ColumnDefinition();
            columnDefinition1.Width = new GridLength(1, GridUnitType.Auto);
            columnDefinition2.Width = new GridLength(1, GridUnitType.Star);

            grid.ColumnDefinitions.Add(columnDefinition1);
            grid.ColumnDefinitions.Add(columnDefinition2);

            foreach (var gt in ApplicationData.Instance.GeocacheContainers)
            {
                RowDefinition rowDefinition = new RowDefinition();
                rowDefinition.Height = GridLength.Auto;
                grid.RowDefinitions.Add(rowDefinition);

                var cb = new CheckBox();
                cb.IsChecked = Values.Contains(gt.Name);
                grid.Children.Add(cb);
                Grid.SetRow(cb, grid.RowDefinitions.Count - 1);
                Grid.SetColumn(cb, 0);

                var txt = new TextBlock();
                txt.Text = gt.Name;
                grid.Children.Add(txt);
                Grid.SetRow(txt, grid.RowDefinitions.Count - 1);
                Grid.SetColumn(txt, 1);
            }

            return grid;
        }
开发者ID:GlobalcachingEU,项目名称:GSAKWrapper,代码行数:33,代码来源:ActionImplementationGeocacheContainerMultiple.cs

示例15: MyListViewItem

 public MyListViewItem(Label PCName, TextBox PasswordTextBox, TextBox PortTextBox, CheckBox SelectionCheckBox)
 {
     this.PCName = PCName;
     this.PasswordTextBox = PasswordTextBox;
     this.PortTextBox = PortTextBox;
     this.SelectionCheckBox = SelectionCheckBox;
 }
开发者ID:giulioambrogi,项目名称:RemoteDesktopWPF,代码行数:7,代码来源:MyListViewItem.cs


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