winform控件

5只猫 5只猫     2022-09-22     494

关键词:

一:ComBobox 下拉框

获取当前选中的item

 private void ChooseProvinceBox_SelectedValueChanged(object sender, EventArgs e)
 {
     var comboBox = sender as ComboBox;
        string text= comboBox.SelectedItem.ToString();
 }

当然也可以直接通过下拉框的名称+点直接将窗体里的下拉框找出来。也可以像我一样,通过sender转一下类型,找到当前事件中的ComboBox。

selectedValue selectedIndex 属性

selectedValue:当前选择的值

selectedIndex:当前所选择的索引,比如中途下拉框的内容会发生变化,索引也会发生变化。

 二:RadioButton 单选框

(Radio是收音机的意思,收音机上的按钮就是单选的,按下去的那种,所以理解成单选框 ps:自己瞎理解)

它有一个Checked的属性,用于记录是否被选。true为被选中,false为没选中。

它有一个CheckedChanged事件。

 private void ChooseGenderradioButton_CheckedChanged(object sender, EventArgs e)
 {
        var radioButton = sender as RadioButton;
        //MessageBox.Show(radioButton.Checked.ToString());
        //如果为true 则被选 
         if (radioButton.Checked)
         {
                
              
         }
         else //取消选择
         {
                
         }
}

三:CheckBox 复选框

与上面的单选框而言,它是可以多选的。

同样也有Checked属性和CheckedChanged事件。

 private void checkBox_CheckedChanged(object sender, EventArgs e)
 {
        var checkBox = sender as CheckBox;
        if (checkBox.Checked)
        {
               
        }
        else //取消选择
        {
             
        }
 }

四:DateTimePicker  日期选择器

 时间选择器,在选择之后有一个CloseUp事件。用于选择后,选择器关闭后触发。

private void dateTimePicker1_CloseUp(object sender, EventArgs e)
{
      MessageBox.Show(this.dateTimePicker1.Value.ToString());
}

五:Timer类 定时器

 这个不是控件,是一个类。

//定义一个定时器
Timer timer = new Timer();
//设置一个时间间隔,每隔5秒一次 timer.Interval
= 5000;
//每隔几秒后触发一次,在该事件里写上你要做的事情 timer.Tick
+= new EventHandler(SetYellowLight);
//定时器是否可用 timer.Enabled
= true;
//定时器开启 timer.Start();
private void SetYellowLight(object sender, EventArgs e)
{
     MessageBox.Show("2333");
}

 

 

 

---some words---

1.combo:小型爵士乐队,三明治等组合食物

2.ComboBox:组合下拉框

3.Radio:收音机

4.RadioButton 单选框

5.Check 复查,检查,核对

5.Checked 选中的,

6.Picker 选择器

7.DateTimePicker 日期选择器

8.Timer 定时器

9.Tick 钟的滴答声

10.Interval 区间,间隔

-----the end-------

winform控件大全

目录1、窗体(Form)2、Label(标签)控件3、TextBox(文本框)控件4、RichTextBox控件5、NumericUpDown控件6、Button(按钮)控件7、GroupBox(分组框)控件8、RadioButton(单选按钮)控件9、CheckBox(复选框)控件10、ListBox(列表框)控件11、Comb... 查看详情

将 WPF 控件与 WinForms 一起使用

】将WPF控件与WinForms一起使用【英文标题】:UsingaWPFControlwithWinForms【发布时间】:2021-05-2818:48:39【问题描述】:我有一个自定义的WPF按钮控件,我想将此控件与WinForm应用程序一起使用。我知道如何使用ElementHost将WPF用户控件与Win... 查看详情

Winforms:创建动态时间线控件

】Winforms:创建动态时间线控件【英文标题】:Winforms:creatingadynamictimelinecontrol【发布时间】:2011-05-3107:23:59【问题描述】:我需要创建一个看起来像这样的winforms控件:目前我正在考虑拍摄一个图片框/面板并覆盖onpaint事件并自... 查看详情

winform跨线程访问控件异常

WinForm跨线程访问控件异常最近做了个WinForm的小项目,遇到个简单的问题记录下。需求:点击”下载“,显示正在下载,下载完后更新状态为”ready“(要求用多线程,避免前台卡死)。做法新建一个线程,在新线程中下在更新... 查看详情

WinForms 栅格地图渲染控件

】WinForms栅格地图渲染控件【英文标题】:WinFormsrastermapsrenderingcontrol【发布时间】:2011-08-3021:14:07【问题描述】:将地图视为一组栅格图块(每个缩放级别一组)。基本上,地图在GoogleMaps、BingMaps等中的存储方式是相同的。我需... 查看详情

winform公共控件

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespace公共控件{publicpartialclass 查看详情

wpf使用winform自定义控件(代码片段)

...引用WindowsFormsIntegration.dllSystem.Windows.Forms.dll2、在要使用WinForm控件的WPF窗体的XAML文件中添加如下内容:xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration... 查看详情

WinForms:使用 c# 添加控件

】WinForms:使用c#添加控件【英文标题】:WinForms:addingacontrolwithc#【发布时间】:2021-07-0603:57:31【问题描述】:我是C#新手,我知道如何动态添加控件,但我不知道如何将该控件设置为this.[control_name]。请注意,这里的this是Form。这... 查看详情

在运行时更改 winforms 控件

】在运行时更改winforms控件【英文标题】:Changewinformscontrolatruntime【发布时间】:2018-10-1812:01:20【问题描述】:我通过以下方式继承了用户控件:控制基础|__ControlInherited1|__ControlInherited2ControlBase包含在每个继承的控件中被覆盖的... 查看详情

C# WinForms 用鼠标拖动控件

】C#WinForms用鼠标拖动控件【英文标题】:C#WinFormsdraggingcontrolswithmouse【发布时间】:2011-06-2211:45:07【问题描述】:我正在使用WinForms在C#中制作日历。我用一个二维的面板数组把它放在一起,在它们里面我有一个代表约会的自定... 查看详情

自定义 Winforms 设计器控件同时缩放和平移控件

】自定义Winforms设计器控件同时缩放和平移控件【英文标题】:ZoomandPancontrolssimultaneouslyforacustomWinformsdesignercontrol【发布时间】:2021-10-1514:59:00【问题描述】:我正在尝试在winforms中创建一个“设计师”。这将向用户呈现一个所见... 查看详情

winform控件

 控件 1.公共控件                               查看详情

WinForms中的WPF控件[关闭]

】WinForms中的WPF控件[关闭]【英文标题】:WPFcontrolsinWinForms[closed]【发布时间】:2011-06-2712:29:35【问题描述】:我是.NET世界的新手,我对winforms的经验很少。我想知道是否可以将WPF与Winforms混合使用。我的意思是我可以在传统的Wind... 查看详情

winform控件

一:ComBobox下拉框获取当前选中的itemprivatevoidChooseProvinceBox_SelectedValueChanged(objectsender,EventArgse) {    varcomboBox=senderasComboBox;stringtext=comboBox.SelectedItem.ToString(); }当然也可以直接通过下拉框的名称+点直接将窗 查看详情

winform公共控件及属性

1/button(按钮):autosize:自动匹配尺寸location:确定控件位置margin:控件与控件之间的尺寸maxsise:控件的最大尺寸minsize:控件的最小尺寸enable:确定是否启用控件visible:确定控件是否可见name:指示代码中用来标志该对象的名称tag:用... 查看详情

winform创建自定义控件

虽然VS为我们提供了很多控件可以使用,但有时候这些控件仍然不能满足我们的要求,比如我们要对部分控件进行一些个性化的定制,例如美化控件,这时候就需要自己绘制控件,或是在原有控件的基础上进行修改自定义控件分... 查看详情

winform1

一、窗体的各种属性二、控件1.公共控件2.容器控件 3.菜单控件  查看详情

wpf精修篇winform嵌入wpf控件

原文:WPF精修篇Winform嵌入WPF控件首先创建WPF控件库这样就有了一个WPF界面在wpf中增加界面等在winform中增加WPFDLL 重新生成解决方案在左侧工具栏出现WPF控件拖到窗体效果 查看详情