随笔分类 -  C# WinForm/WPF

摘要:private void mainform_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; System.Drawing.Bitmap xzfy = new System.Drawing.Bitmap(Application.StartupPath + "//img/背景.png"); g.DrawImage(xzfy, this.ClientRectangle); } private void loa... 阅读全文
posted @ 2013-06-22 19:51 双魂人生 阅读(4328) 评论(0) 推荐(1) 编辑
摘要:0.新建窗体 及添加按钮1. 执行如下按钮事件 private void btnFormMax_Click(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } else { this.WindowState = FormWindowState.Maximized; } } 窗体最大化时 非全屏 不会遮盖任务栏 此时this.FormBorderStyle 默认为 Sizable2. 执行如下按 阅读全文
posted @ 2013-06-22 19:42 双魂人生 阅读(7395) 评论(0) 推荐(2) 编辑
摘要:当船体设置为FormborderStyle='none'[DllImport("user32.dll")]public static extern bool ReleaseCapture();[DllImport("user32.dll")]public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);public const int WM_SYSCOMMAND = 0x0112;public const int SC_MOVE = 阅读全文
posted @ 2013-06-22 12:06 双魂人生 阅读(606) 评论(0) 推荐(0) 编辑
摘要:DateTime dt = DateTime.Now; //本月第一天时间 DateTime dt_First = dt.AddDays(1 - (dt.Day)); //获得某年某月的天数 int year = dt.Date.Year; int month = dt.Date.Month; int dayCount = DateTime.DaysInMonth(year, month); //本... 阅读全文
posted @ 2013-06-16 12:37 双魂人生 阅读(6970) 评论(0) 推荐(0) 编辑
摘要:private void dgvEmployee_MouseDown(object sender, MouseEventArgs e) { DataGridView.HitTestInfo rows = this.dgvEmployee.HitTest(e.X, e.Y); if (e.Button == MouseButtons.Right) { if (rows.RowIndex > -1 && rows.ColumnIndex > -1) ... 阅读全文
posted @ 2013-06-13 14:47 双魂人生 阅读(285) 评论(0) 推荐(0) 编辑
摘要:/// <summary>为 DataGridView 添加行号。</summary> public static void ShowRows_DataGridView_RowPostPaint(DataGridView dgv, object sender, DataGridViewRowPostPaintEventArgs e) { Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth... 阅读全文
posted @ 2013-06-13 14:43 双魂人生 阅读(315) 评论(0) 推荐(0) 编辑
该文被密码保护。
posted @ 2013-06-13 14:35 双魂人生 阅读(0) 评论(0) 推荐(0) 编辑
该文被密码保护。
posted @ 2013-06-13 12:19 双魂人生 阅读(1) 评论(0) 推荐(0) 编辑
该文被密码保护。
posted @ 2013-06-12 16:47 双魂人生 阅读(0) 评论(0) 推荐(0) 编辑
摘要:禁止Form窗口调整大小方法:FormBorderStyle 设为FixedSingle;不能使用最大化窗口: MaximuzeBox 设为False;不能使用最小化窗口:MinimizeBox 设为False;禁止combobox输入方法:将DropDownStyle 设为DropDownList 阅读全文
posted @ 2013-06-10 10:15 双魂人生 阅读(23233) 评论(0) 推荐(1) 编辑
摘要:using System;using System.Collections.Generic;using System.Windows.Forms;using XLuSharpLibrary.DbAccess;using System.Runtime.InteropServices;//使用DllImport的必须。using System.Diagnostics;//引入Process 类namespace BHair{ static class Program { private const int WS_SHOWNORMAL = 1; [DllImp... 阅读全文
posted @ 2013-06-06 16:10 双魂人生 阅读(684) 评论(0) 推荐(0) 编辑
摘要:首先,添加托盘控件,在vs工具箱里直接把notifyIcon拖到主界面即可 其次、进行一系列的操作,比如双击打开,退出等 /// <summary> /// 显示托盘图标 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mainform_Resize(object sender, EventArgs e) { if (this.WindowS... 阅读全文
posted @ 2013-06-06 11:41 双魂人生 阅读(590) 评论(0) 推荐(0) 编辑
摘要:插入行 DataGridViewRow row = new DataGridViewRow(); dgvProject.Rows.Add(row);删除行 删除当前行 dgvProject.Rows.Remove(dgvProject.CurrentRow); 阅读全文
posted @ 2013-05-28 17:37 双魂人生 阅读(341) 评论(0) 推荐(0) 编辑
摘要:看到上面的图,很明显就是让在DataGrilView中修改消费次数的,这就要求我们要在DataGrilView可以更新数据,那么怎么做到呢,其实很简单首先、dataGrilView要启用编辑才可以其次、看看下面的代码 private void btnOk_Click(object sender, EventArgs e) { Pays objPay = new Pays(); if (this.ValidateData()) { bool fig = false; ... 阅读全文
posted @ 2013-05-28 15:54 双魂人生 阅读(1775) 评论(0) 推荐(1) 编辑
摘要:图一 在实际的应用软件开发中,对类似表格的格式有着特殊的需求,比如像上面两个就是,图一 项目名称有很多,要求用下拉框显示出来,图二要求用复选框来选择要操作的行这就要求我们需要改变一下列的类型,并执行相关的操作,下面就来简单说说如何实现这些一、首先在DataGrilView中改变列的显示类型 在DataGirlView中内置了这些类型,我们只需要根据需要选择下即可, 然后在Item或者相关地方赋值即可,这是手动改变状态,并添加数据,下面看看如何动态添加数据 List<SPItems> lstItems = new SPItems().SelectList("0", 阅读全文
posted @ 2013-05-28 12:04 双魂人生 阅读(1359) 评论(0) 推荐(0) 编辑
摘要:绑定TreeView: /// <summary>加载职位列表</summary> private void LoadPostList() { this.tvwPost.Nodes.Clear(); List<Post> lstPost = new Post().SelectList(); TreeNode objTreeNode = new TreeNode(); objTreeNode.Name = "0"; objTreeNode.Text = "显示... 阅读全文
posted @ 2013-05-28 11:16 双魂人生 阅读(2259) 评论(0) 推荐(0) 编辑
摘要:最近安装一个x64位的系统,用vs打开以前的软件出错了:未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序,原来是系统默认是x64的需要修改为x86的,设置方法:打开vs,生成->配置管理器-> 平台->点击Any Cpu选项卡->新建->新建平台->X86 就可以了 又出现了另外一个问题了,项目是c/s的,用了一个皮肤类库Sunisoft,允许的时候报错:找不到类型或命名空间名称“Sunisoft”(是否缺少 using 指令或程序集引用?)解决办法把原来的debug中的文件拷到x86下面的Debug即可 阅读全文
posted @ 2013-05-18 15:52 双魂人生 阅读(372) 评论(1) 推荐(1) 编辑
摘要:最近做的wpf项目中,在开发的时候,把图片放到了bin下面,采用了imagePath =System.IO.Directory.GetCurrentDirectory()+"/images/starShow.jpg";获得图片是可以的,可是发布之后却获取不到图片,这让我很纠结,后来通过把图片添加到了资源中,然后调用资源即可解决了问题 imagePath = "pack://application:,,,/Financial;component/Properties/../images/star/starShow.jpg";imageBrush.Image 阅读全文
posted @ 2013-01-15 16:53 双魂人生 阅读(9183) 评论(0) 推荐(1) 编辑
摘要:这里把wpf中几种常用样式总结一下,后期可以直接拷贝使用,呵呵一、ButtonView Code <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!--定义按钮样式·通用按钮--> <Style TargetType="Button"> <Sette 阅读全文
posted @ 2013-01-15 11:44 双魂人生 阅读(8464) 评论(1) 推荐(2) 编辑
摘要:ListBox可以用来显示类似web中新闻列表的样式,显示也比较灵活,可以自定定义模板 <DataTemplate x:Key="listBoxTemplate"> <StackPanel Margin="4"> <DockPanel> <Grid> <Grid.RowDefinitions> <RowDefinition /> <Row... 阅读全文
posted @ 2013-01-15 11:35 双魂人生 阅读(12858) 评论(0) 推荐(1) 编辑