![](https://img-blog.csdnimg.cn/20190918140037908.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Winform
winform控件学习
Bridge_go
这个作者很懒,什么都没留下…
展开
-
C#winfrom中DataGridView实现行标题
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e){ using (SolidBrush b = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor)) { e.Graphics.DrawString((e.RowIndex + 1).ToString(Syste.原创 2021-06-03 17:13:03 · 831 阅读 · 0 评论 -
C#winform数据绑定
1.DataBindings控件基类(Control),有一个DataBindings对象,它是一个ControlBindingCollection类,这个类继承与BindingsCollection,里面有一个Binding的列表对象,其中Binding对象是一个记录了属性名,数据源,数据成员等的对象。建立一个People类,用于数据绑定:public class People{ public string Name { get; set; } public int...原创 2021-04-26 11:40:48 · 6938 阅读 · 0 评论 -
2048
一、效果Gif二、Mark块 public partial class Block : UserControl { public Block() { this.Size = new Size(60, 60); MinFontSize = 4; MaxFontSize = 40; } /// <summary> ...原创 2021-03-19 16:56:36 · 77 阅读 · 0 评论 -
C#winform控件的各种坐标获取
一、窗体绿色边框框住的区域:屏幕 橙色边框框住的区域:窗体 黄色边框框住的区域:窗体工作区1.边框窗体的FormBorderStyle可以设置以下的值,每个值导致窗体的边框的宽度不一样,但是可以发现的是左、右、下边框的宽度是一样的: // // 摘要: // 指定窗体的边框样式。 [ComVisible(true)] public enum FormBorderStyle { // // 摘要:..原创 2021-03-12 10:49:29 · 10310 阅读 · 0 评论 -
C#winform可设置四个角倒角的panel控件
using System;using System.ComponentModel;using System.Drawing;using System.Runtime.InteropServices;using System.Windows.Forms;namespace WindowsFormsApp3{ public partial class RoundPanel : Panel { [DllImport("user32.dll")] st.原创 2021-01-29 18:32:28 · 1263 阅读 · 0 评论 -
C#针对PropertyGrid控件修改其常用的几个特性的值
using System;using System.ComponentModel;using System.Reflection;namespace PropertyGridUse{ public class PropertyAttribute<T> { /// <summary> /// 修改propertyName名称的属性Category特性的值 /// </summary> .原创 2020-12-03 14:43:05 · 1774 阅读 · 1 评论 -
C#winform界面的语言切换
1、效果图原创 2020-11-27 18:08:42 · 830 阅读 · 0 评论 -
C#可以自由移动和伸缩的TextBox
效果图主题代码using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;namespace FrameControl{ public partial class MoveTextBox : UserControl { /// <summary> /// 鼠标点击该控件时的事件 ...原创 2020-09-11 10:37:27 · 998 阅读 · 1 评论 -
C#自己无聊写的2048小游戏
https://download.csdn.net/download/breakbridge/12029775原创 2020-03-20 17:53:45 · 569 阅读 · 0 评论 -
C#自己无聊写的俄罗斯方块游戏
https://download.csdn.net/download/breakbridge/12029766原创 2020-03-20 17:52:46 · 204 阅读 · 0 评论 -
C#实现非枚举类型的在属性控件中可下拉选择(二)
前言:相较于之前文章,用这种方式优点是可以修改在属性控件上显示的效果,然后重新绑定就可以了1.效果图2.使用举例PropertyGridProperty propertyGridProperty = new PropertyGridProperty();Property p1 = new Property("自定义", "名称", "Name", "", "B...原创 2020-03-18 11:22:32 · 505 阅读 · 0 评论 -
C#实现非枚举类型的在属性控件中可下拉选择(一)
1.效果图2.对象类 public class People { [Category("自定义")] [TypeConverter(typeof(OptionValuesTypeConvertor))] [OptionCollection(1, 54, 6)] public decimal ID...原创 2020-03-18 10:43:04 · 348 阅读 · 0 评论 -
C#在属性窗口中展示如Size一样的对象
1.效果图2.对象和控件using System.ComponentModel;using System.Drawing;using System.Windows.Forms;namespace AttributeTest{ public partial class UserControl1 : UserControl { p...原创 2020-03-18 09:52:01 · 336 阅读 · 0 评论 -
C#简单的日志打印控件
partial class DataGridViewInfo{ /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// ...原创 2020-01-14 14:42:05 · 1246 阅读 · 0 评论 -
C#设置控件居中显示
1.在父控件中居中/// <summary>/// 控件在父控件中居中/// </summary>/// <param name="ctr">要设置的控件</param>/// <param name="isLR">左右居中</param>/// <param name="isUD">上下居中&l...原创 2020-01-09 17:58:19 · 2309 阅读 · 0 评论 -
C#设置控件 Enabled 为 false 时背景色不改变
class CtrEnabled{ [System.Runtime.InteropServices.DllImport("user32.dll ")] static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc); [System.Runtime.InteropServices.DllImpo...原创 2020-01-09 17:52:06 · 1781 阅读 · 1 评论 -
C#winfrom实现文件的拖曳效果
将要实现拖曳的窗体订阅下列两个事件private void Form1_DragEnter(object sender, DragEventArgs e){ if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; //设置拖曳时的操作,是复制或者是剪切等...原创 2020-01-09 11:01:54 · 204 阅读 · 0 评论 -
C# winform在运行过程中鼠标左键移动控件位置
Point _downPoint; private void button1_MouseDown(object sender, MouseEventArgs e) { _downPoint = new Point(e.X, e.Y); } private void button1_Mouse...原创 2019-02-12 13:59:55 · 898 阅读 · 2 评论 -
C# winform 解决加载闪烁,背景透明等问题
using System.Windows.Forms; /// <summary> /// 解决加载闪烁,背景透明等问题 /// </summary> protected override CreateParams CreateParams { get...原创 2019-02-12 14:15:33 · 1391 阅读 · 0 评论 -
C#中Form窗口中的控件不显示
问题:在vs2010中的窗体设计时,明明在designer.cs中有控件的代码,但是在窗体设计器中没有显示控件解决:看窗体构造函数中是否有InitializeComponent(); 有可能在designer.cs中没有将控件添加入父控件 例如:this.Controls.Add(this.groupBox1);ps:我之前遇到的就是这样,不知道怎么回事窗体中不显示控件了,后...原创 2019-03-05 13:42:56 · 9980 阅读 · 2 评论 -
C#winform带Scroll的Panel中控件的坐标设置问题
1.Panel中控件Location设置是基于界面上位置 《(0,0)永远在左上角》,和Scroll没关系2.当滑动Scroll时,Panel中的所有控件的Location都发生了改变3.当Scroll不在原始位时设置控件Location为(0,0)会导致Panel上方有空白...原创 2019-04-18 16:17:25 · 1799 阅读 · 0 评论 -
C#窗体自定义控件特性(Attribute)的使用
摘要: C#中的自定义控件中的属性(Property)、事件(Event)及一些相关特性(Attribute)的总结今天学习了下C#用户控件开发添加自定义属性的事件,主要参考了MSDN,总结并实验了一些用于开发自定义属性和事件的特性(Attribute)。在这里先说一下我的环境:操作系统:Windows7旗舰版(Service Pack 1)VS版本:Microsoft Visua...原创 2020-11-20 16:02:57 · 1141 阅读 · 0 评论 -
C#自定义控件之数字文本框
public class TextBoxNumber : TextBox { public TextBoxNumber() { this.KeyPress += textBox_KeyPress; this.Leave += textBox_Leave; } doub...原创 2019-09-09 16:36:58 · 936 阅读 · 0 评论 -
C#winform 自定义模仿MessageBox的对话框
public partial class MesBox : Form { int _maxWidth = 802; int _maxHeight = 704; int _btnAllow; Dictionary<Keys, Button> _dictKBtn = new Dictionary<Ke...原创 2019-09-29 09:11:58 · 1798 阅读 · 0 评论 -
C#自定义控件之下拉列表框
设置 DropDownStyle 为DropDownList 将DrawMode 改为OwnerDrawFixed 添加DrawItem 事件 样式就变为下面这样,但是只能在列表中选择,而不能手动输入 public class ComBox : ComboBox { public ComBox() { ...原创 2019-02-12 13:48:56 · 11618 阅读 · 0 评论