文章分类 -  WinForm

摘要:微软并没有自带这种禁用的方法,所以要写点代码来完成此功能。首先添加下面两个类:public class DataGridViewDisableButtonColumn : DataGridViewButtonColumn { public DataGridViewDisableButtonColumn() { this.CellTemplate = new DataGridViewDisableButtonCell(); } } public class DataGridViewDisableButtonCell... 阅读全文
posted @ 2014-04-04 09:56 超级塞亚人 阅读(781) 评论(0) 推荐(0)
摘要:e.Handled = true; if ((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar == (char)8)) { if ((e.KeyChar == (char)8)) { e.Handled = false; return; } else { int len = this.txtOrderAccount.Text.Trim().Length; ... 阅读全文
posted @ 2014-04-01 15:55 超级塞亚人 阅读(580) 评论(0) 推荐(0)
摘要:private void btn_Query_Click(object sender, EventArgs e){ this.AddTreeNodeToList(); string sQueryKey = this.txt_QueryKey.Text.Trim(); if (!string.IsNullOrEmpty(sQueryKey) && (this.LstTreeNode.Any())) { if (this.NodeIndex != 0) { this.NodeIndex++; } ... 阅读全文
posted @ 2013-07-26 15:54 超级塞亚人 阅读(194) 评论(0) 推荐(0)
摘要:DataGridViewSelectedRowCollection selectedRowCollection = this.dgdWorkUnit.DataGrid.SelectedRows; List<DataGridViewRow> deleteViewRowList = new List<DataGridViewRow>(); if (selectedRowCollection.Count > 0) { //选中的是整行 deleteViewRowList.A... 阅读全文
posted @ 2013-04-08 10:02 超级塞亚人 阅读(574) 评论(0) 推荐(0)
摘要:DataGridView控件是CS架构中用的比较频繁的一个控件,里面提供了checkbox列的功能,可是却没有在列头给出checkbox控件用于全选/全部取消所有行的功能,确实是个遗憾,这里就通过绘制实现这个功能.添加一个帮助类DataGridViewCheckBoxHeaderCell,用于绘制列头checkbox和创建鼠标单击事件,代码如下: public class DataGridViewCheckBoxHeaderCell : DataGridViewColumnHeaderCell { public delegate void DataGridViewCheck... 阅读全文
posted @ 2013-01-02 22:19 超级塞亚人 阅读(593) 评论(0) 推荐(0)
摘要:有时候在项目里面需要用到类似于百度那种自动索引的功能,在WinForm里面我采用的是用一个TextBox和一个ListBox结合来实现的,大致效果如下图所示:详细的代码如下:View Code using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace AutoComplete{ ... 阅读全文
posted @ 2012-12-25 15:45 超级塞亚人 阅读(269) 评论(0) 推荐(0)
摘要:简单测试了一下,觉得还是比MS自带的要好一点,新建一个项目,添加一个MyMsgBox的窗体,该窗体里面的代码如下:完整的Demo:MessageBox Demousing System;using System.Collections.Generic;using System.Text;using System.Drawing;using System.Drawing.Drawing2D;using System.Windows.Forms;using System.Runtime.InteropServices;namespace MsgBox{ public partial clas... 阅读全文
posted @ 2012-12-06 09:22 超级塞亚人 阅读(617) 评论(0) 推荐(0)
摘要:/*DataGridView 实现行[Row]的上下移动,我这里用到了SelectedRows[0],而没用CurrentRow是有原因的 主要是这两段代码: dataGridView1.Rows[rowIndex - 1].Selected = true; dataGridView1.Rows[rowIndex].Selected = false; 这两行代码大家因该都能看懂,移上去的哪行选中状态,移下去的的取消选中状态. 如果我用dataGridView1.CurrentRow.Cell[0].Value 他取得的值仍然是rowIndex索引行的值 要使用... 阅读全文
posted @ 2012-08-30 14:18 超级塞亚人 阅读(1164) 评论(0) 推荐(0)
摘要:/// <summary> /// 上下移动 ListBox 内的项。 /// </summary> /// <param name="listbox">控件名 ListBox</param> /// <param name="type"> 0- 向上 1-向下</param> /// <returns>int 0-成功 1-到顶了 2-到底了 3-要选择一项。</returns> private int ListBox_UpNext(ListBox list 阅读全文
posted @ 2012-08-24 18:30 超级塞亚人 阅读(129) 评论(0) 推荐(0)
摘要:做了很多Winform的项目,对于数据导入,一直也有自己的理解,由于一般的业务系统,经常性的数据导入时很正常的业务需求,因为毕竟使用Excel来操作数据也很方便,或者由于系统之间的数据交换需要,我们需要提供一个入口给客户导入所需要的数据。但是导入数据的时候,不同的业务数据对应不同的Excel文件,很难做到统一,但如果是每个业务模型,都创建一个不同的导入界面来操作Excel数据,又会觉得可能某种程度上重复劳动,增加开发及维护成本。那么有无一种介于两者之间的方法,来实现效率的最优化,并且能够统一利用好一个导入的界面呢,在开发领域,只要能想到的,一般也能做到,由于工作的需要,在我的Winform开发 阅读全文
posted @ 2012-07-19 16:27 超级塞亚人 阅读(258) 评论(0) 推荐(0)
摘要:public void listViewToDataTable(ListView lv, DataTable dt) { int i, j; DataRow dr; dt.Clear(); dt.Columns.Clear(); //生成DataTable列头 for (i = 0; i < lv.Columns.Count; i++) { dt.Columns.Add(lv.Columns[i].Text.Trim(), typeof(String)); if (dt.Columns[i].ColumnName.Equals("显示名称")) { dt.Column 阅读全文
posted @ 2012-07-12 11:43 超级塞亚人 阅读(494) 评论(0) 推荐(0)