winform

WinForm DataGridView分页功能

瘦欲@ 提交于 2019-11-29 18:50:39
WinForm 里面的DataGridView不像WebForm里面的GridView那样有自带的分页功能,需要自己写代码来实现分页,效果如下图: 分页控件 .CS: 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Windows.Forms; 9 using System.Data.SqlClient; 10 11 namespace allenPageTest 12 { 13 public partial class Form2 : Form 14 { 15 public Form2() 16 { 17 InitializeComponent(); 18 } 19 20 private void Form2_Load(object sender, EventArgs e) 21 { 22 BindDataWithPage(1); 23 } 24 25 //总记录数 26 public int RecordCount = 0; 27 private string

Winform中跨窗体设置Zedgraph的属性并刷新曲线图

只愿长相守 提交于 2019-11-29 18:29:10
场景 在使用ZedGraph时,经常有图形选项功能,设置曲线图相关属性后, 点击保存会设置另一个窗体的属性并刷新图。 效果 实现 在设置图形的选项的类中,声明委托和事件 //委托的定义 public delegate void ReloadPanelDelegete(); //事件声明 public static event ReloadPanelDelegete reloadPanelEvent; 在当前窗体的确定按钮的点击事件中 将相关曲线图的Y轴以及X轴的相关属性存到xml配置文件中,然后调用方法 去刷新曲线图,使其重新加载。 private void confirmbButton_Click(object sender, EventArgs e) { #region 获取X轴的属性并赋值给XAxisModel //对X轴的属性配置文件进行保存 //根据控件的 System.Windows.Forms.Control.Name 属性搜索控件并生成由所有匹配项组成的数组。 //如果搜索所有子控件,则为 true;否则为 false。 XAxisModel xAxisModel = new XAxisModel(); //获取标题 RadioGroup radioGroupX = this.Controls.Find("radioGroupX", true)[0] as

WinForm打包

女生的网名这么多〃 提交于 2019-11-29 16:12:45
首先要在想要打包的项目下创建一个新的项目, 创建好setup项目,之后点击属性,去修改打包软件的名字,ProductName。。。。可以选填 到此已经创建好了setup工程了,那么下面开始将要打包的debug文件下的内容都copy到Application Folder中。 点击Application Folder ->Add -> File ,把要添加内容Ctrl+A 全选,之后加载完。(注意的是:如果是文件夹的话,需要在 Application Folder ->Add-> Folder ,文件夹的里面路径和内容要完全符合debug中) 到此,想要打包的所有debug文件下的内容都导入完毕, 然后点击Application Folder ->Add ->Project Output , 点击ok 后,会出现如下内容,然后点击这个Output-> 创建一个快捷方式,可以自己将快捷方式更名。 之后将修改好的快捷方式,拖拽到User's Desktop Menu中 。方便在菜单栏和桌面上看到这个打包程序的快捷方式。(快捷方式的属性中可以选择ico图标) 下面是准备卸载任务,打开Application Folder ->add ->file , 之后再地址栏上输入C:\Windows\System32 在查找栏上填写 msiexec.exe,找到后点击open . 再将msiexec

(六十六)c#Winform自定义控件-图标字体

梦想的初衷 提交于 2019-11-29 09:54:25
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。 GitHub: https://github.com/kwwwvagaa/NetWinformControl 码云: https://gitee.com/kwwwvagaa/net_winform_custom_control.git 如果觉得写的还行,请点个 star 支持一下吧 欢迎前来交流探讨: 企鹅群568015492 麻烦博客下方点个【推荐】,谢谢 NuGet Install-Package HZH_Controls 目录 https://www.cnblogs.com/bfyx/p/11364884.html 用处及效果 获取一个image HZH_Controls.FontImages.GetImage(样式枚举, 大小, 前景色,背景色); 获取一个icon HZH_Controls.FontImages.GetIcon(样式枚举, 大小, 前景色,背景色); UCBtnImg设置图标,可以使用属性ImageFontIcons 准备工作 下载字体文件 http://www.fontawesome.com.cn/faicons/ https://www.elegantthemes.com/blog/resources/elegant-icon-font 如果想直接要字体文件

winform学习(8)RichTextBox控件

让人想犯罪 __ 提交于 2019-11-29 07:10:31
RichTextBox控件允许用户输入和编辑文本的同时提供了比普通的TextBox控件更高级的格式特征。 RichTextBox的控件标识符.SelectionColor = Color.Blue; 更改选中字符的颜色 RichTextBox的控件标识符.SelectionFont = new Font("隶书",20); 更改选中字符的字体格式和大小 .SelectionBullet = true;添加项目符号(前面加一个 ●) .SelectionBackColor 背景色,底纹 来源: https://www.cnblogs.com/1016391912pm/p/11462740.html

winform学习(7)Label控件、Button控件、TextBox控件

扶醉桌前 提交于 2019-11-29 07:08:15
Label控件是System.Windows.Forms.Label 类提供的控件。 作用:主要用来提供其他控件的描述文字,例如:登录窗体上的用户名、密码(输入框前面的字) Button控件是System.Windows.Forms.Button 类提供的控件。 作用:最常使用的就是编写处理按钮的Click事件及MouseEnter事件代码。 TextBox控件是System.Windows.Forms.TextBox 类提供的控件。(文本输入框) 提供了文本输入和编辑的功能 AcceptsReturn属性要和AcceptsButton属性结合使用,将AcceptsReturn设置为False,AcceptsButton填入一个button按钮,在文本框中按下Enter键时不会换行,会执行这个button的绑定方法。 TextBox的默认事件是TextChanged,及当文本框中的字符改变时就会触发该事件。 来源: https://www.cnblogs.com/1016391912pm/p/11461250.html

(五十五)c#Winform自定义控件-管道

徘徊边缘 提交于 2019-11-29 06:43:41
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。 GitHub: https://github.com/kwwwvagaa/NetWinformControl 码云: https://gitee.com/kwwwvagaa/net_winform_custom_control.git 如果觉得写的还行,请点个 star 支持一下吧 欢迎前来交流探讨: 企鹅群568015492 麻烦博客下方点个【推荐】,谢谢 NuGet Install-Package HZH_Controls 目录 https://www.cnblogs.com/bfyx/p/11364884.html 用处及效果 准备工作 使用GDI+画的,用到了三角函数,如果不了解可以先行百度 开始 添加一个类UCConduit,继承UserControl 添加几个属性 1 /// <summary> 2 /// The conduit style 3 /// </summary> 4 private ConduitStyle conduitStyle = ConduitStyle.Horizontal_None_None; 5 6 /// <summary> 7 /// Gets or sets the conduit style. 8 /// </summary> 9 /// <value

C#winform设置回车事件

馋奶兔 提交于 2019-11-29 06:37:17
拿登录页设置为例: 输入用户名后回车,自动跳转到密码输入框,密码输入之后回车,触发点击登录事件。 用户名处代码: private void txt_user_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') this.txt_pass.Focus(); } 密码处代码: private void txt_pass_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') this.btn_login.PerformClick(); } 登录按钮事件: private void btn_login_Click(object sender, EventArgs e) { if (this.txt_user.Text.Trim() == "") { MessageBox.Show("请输入用户名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txt_user.Focus(); return; } if (this.txt_pass.Text.Trim() == "") { MessageBox.Show("请输入密码!", "提示",

C#winform设置回车事件

我怕爱的太早我们不能终老 提交于 2019-11-29 06:20:31
拿登录页设置为例: 输入用户名后回车,自动跳转到密码输入框,密码输入之后回车,触发点击登录事件。 用户名处代码: private void txt_user_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') this.txt_pass.Focus(); } 密码处代码: private void txt_pass_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') this.btn_login.PerformClick(); } 登录按钮事件: private void btn_login_Click(object sender, EventArgs e) { if (this.txt_user.Text.Trim() == "") { MessageBox.Show("请输入用户名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txt_user.Focus(); return; } if (this.txt_pass.Text.Trim() == "") { MessageBox.Show("请输入密码!", "提示",

C#开发WinForm两个窗体之间传递参数

爱⌒轻易说出口 提交于 2019-11-29 06:18:11
步骤 可以通过构造函数在两个窗体间传递参数。例子由Form1传递到Form2(Form1和Form2对应控件略)。 Form1代码: 1 //…… 2 public partial class Form1 : Form 3 { 4 public Form1() 5 { 6 InitializeComponent(); 7 } 8 9 private void button1_Click(object sender, EventArgs e) 10 { 11 Hide(); 12 Form2 form = new Form2(textBox1.Text); 13 form.ShowDialog(); 14 Show(); 15 } 16 } 17 //…… Form2代码: 1 //…… 2 string text ; //用于获取传递的参数 3 public Form2() 4 { 5 InitializeComponent(); 6 } 7 8 public Form2(string text) 9 { 10 InitializeComponent(); 11 this.text = text; 12 } 13 14 private void Form2_Load(object sender, EventArgs e) 15 { 16 label1.Text = "Hello,