摘要: //创建数据库连接 SqlConnection con = new SqlConnection("server=.;database = test; uid = sa; pwd = 123456"); try { //打开数据库连接 con.Open(); //数据适配器,传输数据库数据 SqlDataAdapter sda = new SqlDataAdapter("select * ... 阅读全文
posted @ 2012-03-26 11:11 ghypnus 阅读(3940) 评论(1) 推荐(1) 编辑
摘要: //按钮启动第二个窗口 private void button1_Click(object sender, EventArgs e) { //另起一个线程启动第二个窗口 new Thread(showF2).Start(); this.Close(); } //启动第二个窗口的方法 void showF2() { Form2 f2 = new Form2(); //这句很重要,不能用f2... 阅读全文
posted @ 2012-03-25 13:34 ghypnus 阅读(1866) 评论(8) 推荐(2) 编辑
摘要: View Code 1 private void Form1_Load(object sender, EventArgs e) 2 { 3 new Thread(copyFileAndProgressBar).Start(); 4 progressBar1.Value = 0; 5 timer1.Interval = 2000; 6 timer1.Start(); 7 } 8 9 private void timer1_Tick(o... 阅读全文
posted @ 2012-03-25 01:29 ghypnus 阅读(335) 评论(0) 推荐(0) 编辑
摘要: //定义哈希表 private Hashtable ht = new Hashtable(); private void Form1_Load(object sender, EventArgs e) { StreamReader sr = null; try { //参数一:路径,参数二:编码格式 sr = new StreamReader(@"C:\Users\Administrator\Desktop\user... 阅读全文
posted @ 2012-03-24 22:01 ghypnus 阅读(296) 评论(0) 推荐(0) 编辑
摘要: DataGridViewTextBoxColumn dc = new DataGridViewTextBoxColumn();dc.HeaderText = "新增列";dataGridView1.Columns.Add(dc); 阅读全文
posted @ 2012-03-24 15:48 ghypnus 阅读(317) 评论(0) 推荐(0) 编辑
摘要: private void Form1_Load(object sender, EventArgs e) { //指定托盘图标 this.notifyIcon1.Icon = new System.Drawing.Icon("C:\\Users\\Administrator\\Desktop\\11.ico"); //5000:托盘图标显示5秒 //标题为"系统提示" //内容为"系统正在运行" //ToolTipIcon.Info:提... 阅读全文
posted @ 2012-03-24 09:51 ghypnus 阅读(404) 评论(0) 推荐(0) 编辑
摘要: //单元格点击事件 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { //获取某个单元格的值的数据类型名称 MessageBox.Show(dataGridView1[e.ColumnIndex, e.RowIndex].Value.GetType().Name); } 阅读全文
posted @ 2012-03-24 09:27 ghypnus 阅读(188) 评论(0) 推荐(0) 编辑
摘要: //显示选中的文字 private void showText(string title) { //定义空字符串 string str = string.Empty; //以下确认该字符串的值 if (checkBox1.Checked && !checkBox2.Checked) str = checkBox1.Text; if (checkBox2.Checked && !checkBox1.Checked)... 阅读全文
posted @ 2012-03-24 09:23 ghypnus 阅读(359) 评论(0) 推荐(0) 编辑
摘要: //获取系统版本号 public static string GetOSType() { //定义系统版本 Version ver = System.Environment.OSVersion.Version; string OSType = ""; //Major主版本号 //Minor副版本号 if (ver.Major == 5 && ver.Minor == 0) { ... 阅读全文
posted @ 2012-03-23 23:53 ghypnus 阅读(228) 评论(0) 推荐(0) 编辑
摘要: //4种方式获取字符串中某个元素的出现次数 string china = "中国一词的含义在不同时代也不同," + "大致统一时期略指全国,分裂时多指中原。" + "相传3000你年前,周公在阳国用土圭测度日影" + "测得夏至这一天午时,八尺国表周围景物均没有日影," + "便认为这是大地的中心,因此周朝谓之中国"; //将国字替换为空,少几个就是几个国字 int count0 = china.Length - china.Replace... 阅读全文
posted @ 2012-03-23 23:16 ghypnus 阅读(215) 评论(0) 推荐(0) 编辑