摘要: 注意:该方法最大的不足之处就是会导致表格很卡,忘高手知道怎么规避卡的现象就指点一二(已修正)private void GridDetail_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (GridDetail.CurrentCell.ColumnIndex != 1) return; TextBox tb = e.Control as TextBox; tb... 阅读全文
posted @ 2012-03-23 18:10 ghypnus 阅读(418) 评论(0) 推荐(0) 编辑
摘要: //定义一个List List<string> list = new List<string>(); //添加数组 list.AddRange(new string[] { "11", "12", "13", "22", "23", "24" }); //设置文本框自动完成源 textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource; //设置文本框自动完成模式 ... 阅读全文
posted @ 2012-03-23 17:53 ghypnus 阅读(1396) 评论(0) 推荐(0) 编辑
摘要: //Excel转Sql方法 public static DataTable Excel2DataTable(string filePath, string sheetName) { DataTable dt = null; //HDR=Yes:第一行是列名 //IMEX=1:把数据作为text 类型 string conStr = string.Format("Provider=Microsoft.Ace.OleDb.12.0;Data Source={0};Ex... 阅读全文
posted @ 2012-03-23 13:03 ghypnus 阅读(1158) 评论(0) 推荐(0) 编辑
摘要: Access2003工具 -> 选项 -> 视图 -> 勾选隐藏对象、系统对象工具 -> 安全 -> 用户与组的权限->选择MSysObjects->勾选读取数据Access2007Office按钮->Access选项->当前数据库->导航选项->勾选显示系统对象->数据库工具->用户和权限->用户与组权限->对象名称->选择MSysObjects->勾选读取数据 //将Access中的表名绑定到下拉框 private void Bind2ComboBox() { //Access2003连接 阅读全文
posted @ 2012-03-23 00:06 ghypnus 阅读(683) 评论(0) 推荐(0) 编辑
摘要: 1.新建Excel并保存数据2.追加Excel并自动分页保存数据View Code using System;using System.Collections.Generic;using System.Runtime.InteropServices;using Excel = Microsoft.Office.Interop.Excel;using System.Diagnostics;using System.IO;using System.Collections;using System.Data;namespace AssismentForm{ /// <summary> / 阅读全文
posted @ 2012-03-22 21:41 ghypnus 阅读(430) 评论(2) 推荐(1) 编辑
摘要: View Code using System;using System.Data.SqlClient;using System.Data;namespace Test{ class SQLHelper { //定义数据库连接实例 private static SqlConnection con = CreateCon(); //创建数据库连接静态方法 public static SqlConnection CreateCon() { return new SqlConnection("ser... 阅读全文
posted @ 2012-03-22 20:37 ghypnus 阅读(490) 评论(1) 推荐(0) 编辑
摘要: //1.设置父窗体(主窗体)的AutoScrollMinSize大于父窗体的Size //例如主窗体(400,400), AutoScrollMinSize(500,500) //2.设置主窗体的IsMdiContainer为true private void Form2_Load(object sender, EventArgs e) { //悬浮窗体 Form3 f3 = new Form3(); //制定悬浮Mid子窗体的父窗体是该主窗体 ... 阅读全文
posted @ 2012-03-22 10:44 ghypnus 阅读(657) 评论(0) 推荐(0) 编辑
摘要: bool enterkey; protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { enterkey = false; if (keyData == Keys.Tab) { return true; } return base.ProcessCmdKey(ref msg, keyData); } 阅读全文
posted @ 2012-03-22 09:17 ghypnus 阅读(340) 评论(0) 推荐(0) 编辑
摘要: View Code public class MyProcess { private bool haveMainWindow = false; private IntPtr mainWindowHandle = IntPtr.Zero; private int processId = 0; private delegate bool EnumThreadWindowsCallback(IntPtr hWnd, IntPtr lParam); public IntPtr GetMainWindowHandle(int p... 阅读全文
posted @ 2012-03-21 23:35 ghypnus 阅读(992) 评论(0) 推荐(1) 编辑
摘要: bool bOnlyOneInstance = false;System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.UserAppDataPath.Replace(@"\", "_"), out bOnlyOneInstance);if (!bOnlyOneInstance) { MessageUtil.ShowTips("程序已经运行!"); System.Environment.Exit(0); return; } 阅读全文
posted @ 2012-03-21 23:11 ghypnus 阅读(429) 评论(0) 推荐(0) 编辑