当前位置:网站首页>Check控件
Check控件
2022-08-01 05:07:00 【济南医疗小程序状元】
Check控件
<Window x:Class="WpfApp1.control.Checkbox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1.control"
mc:Ignorable="d"
Title="Checkbox" Height="450" Width="800">
<Grid Name="gridMain">
<Label VerticalAlignment="Top" Width="150" FontSize="20" Background="Orange"
Foreground="White" >MY 的选课</Label>
<CheckBox Content="计算机组成原理" Margin="300,80" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="160" Height="30" FontSize="20"
IsChecked="True"></CheckBox>
<CheckBox Content="网络信息" Margin="300,110" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="120" Height="30" FontSize="20"></CheckBox>
<CheckBox Content="C language" Margin="300,50" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="120" Height="30" FontSize="20" BorderBrush="Blue"></CheckBox>
<Button Content="获取我的选课" Click="Button_Click"
Margin="331,182,0,0" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="120" Height="30" />
</Grid>
</Window>
后台事件
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace WpfApp1.control
{
/// <summary>
/// Checkbox.xaml 的交互逻辑
/// </summary>
public partial class Checkbox : Window
{
public Checkbox()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// 等同于类的实例化 ,对象? 反正知道是处理那个XAML里面的数据,至少要知道的!
UIElementCollection childrenobj= gridMain.Children; // 0.1 通过grid 属性名字,获取子元素方式!
StringBuilder sbfobj = new StringBuilder("我的选课为:");
// 进行遍历
foreach (UIElement item in childrenobj)
{
// 判断
if(item is CheckBox && (item as CheckBox).IsChecked.Value)
{// 判断里面追加,已经获取到的字符串内容 我的选课内容
sbfobj.Append((item as CheckBox).Content+",");
}
}
MessageBox.Show(sbfobj.ToString());
}
}
}
效果
边栏推荐
- SL-12/2过流继电器
- safari浏览器怎么导入书签
- 中国的机器人增长
- Selenium:鼠标、键盘事件
- (Codeforce 757)E. Bash Plays with Functions(积性函数)
- typescript24 - type inference
- y83.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十四)
- The method of solving stored procedure table name passing through variable in mysql
- Excuse me, only primary key columns can be queried using sql in table storage. Does ots sql not support non-primary keys?
- Robot_Framework:常用内置关键字
猜你喜欢
(2022 Nioke Duo School IV) D-Jobs (Easy Version) (3D prefix or)
Robot_Framework:断言
56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)
Excel record of integer programming optimization model to solve the problem
pytorch、tensorflow对比学习—功能组件(优化器、评估指标、Module管理)
状态压缩dp
NDK does not contain any platforms问题解决
UE4 模型OnClick事件不生效的两种原因
(Codeforce 757)E. Bash Plays with Functions(积性函数)
typescript22-接口继承
随机推荐
typescript24 - type inference
25. 这三道常见的面试题,你有被问过吗?
数组问题之《下一个排列》、《旋转图像》以及二分查找之《搜索二维矩阵》
LeetCode 27. 移除元素
typescript23-tuple
USB3.0:VL817Q7-C0的LAYOUT指南(二)
Power button (LeetCode) 212. The word search II (2022.07.31)
pytorch、tensorflow对比学习—功能组件(优化器、评估指标、Module管理)
y83.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十四)
pytroch、tensorflow对比学习—使用GPU训练模型
UE4 从鼠标位置射出射线检测
零序电流继电器器JL-8C-12-2-2
【目标检测】YOLOv7理论简介+实践测试
MySQL-数据操作-分组查询-连接查询-子查询-分页查询-联合查询
Selenium:元素等待
Robot_Framework:断言
7月编程排行榜来啦!这次有何新变化?
MySQL-Data Definition Language-DDLdatebase define language
PaddleX部署推理模型和GUI界面测试结果不一致的解决方法
[MySQL] 多表查询