文章分类 -  c#

上一页 1 ··· 4 5 6 7 8 9 10 下一页
摘要:通过API [DllImport("user32.dll")] public static extern System.Int32 CreateCaret(System.IntPtr hwnd, System.IntPtr hbm,System.Int32 cx, System.Int32 cy); [DllImport("user32.dll")] public st... 阅读全文
posted @ 2009-08-18 15:04 oraclejava 阅读(192) 评论(0) 推荐(0)
摘要:1 private void MoveCmdToLast(TextBox txtCmdInput, String selCmd)//把所选中的命令移动到最下一行然后显示在文本框中 2 { 3 String txtStr = txtCmdInput.Text; 4 int start = txtStr.IndexOf(selC... 阅读全文
posted @ 2009-08-18 15:04 oraclejava 阅读(273) 评论(0) 推荐(0)
摘要:显示动态光标和图标的基本原理:在计时器控件的Tick事件下处理过程把一系列图标或光标赋予给窗体的"iCON"属性,以形成连续播放的图标或光标从而形成动态1.在窗体上添加一个计时器"timer1"控件,并准备一些图标1.ico,2.ico.........和光标1.cur,2.cur.............下面是源码:using System;using System.Collections.Ge... 阅读全文
posted @ 2009-08-18 15:03 oraclejava 阅读(294) 评论(0) 推荐(0)
摘要:protected override void OnFormClosing(FormClosingEventArgs e) { if (MessageBox.Show("你确认要退出该程序吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogRes... 阅读全文
posted @ 2009-08-18 15:02 oraclejava 阅读(589) 评论(0) 推荐(0)
摘要:MessageBox.Show("当前窗体标题栏高度"+(this.Height - this.ClientRectangle.Height).ToString());//获得当前窗体标题栏高度ClientRectangle//获取表示控件的工作区的矩形MessageBox.Show(SystemInformation.PrimaryMonitorSize.ToString()); //获取主显示... 阅读全文
posted @ 2009-08-18 15:01 oraclejava 阅读(456) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1{public parti... 阅读全文
posted @ 2009-08-18 15:01 oraclejava 阅读(178) 评论(0) 推荐(0)
摘要:1. 执行如下按钮事件 private void btnFormMax_Click(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } else { this.WindowState = Form... 阅读全文
posted @ 2009-08-18 15:00 oraclejava 阅读(279) 评论(0) 推荐(0)
摘要:①新建一窗体,拉一Timer控件,Interval值设置为20,双击Timer控件进入事件编写:private void timer1_Tick(object sender, EventArgs e){// 计时器事件if (this.Opacity > 0){this.Opacity -= 0.02;}else {this.timer1.Enabled = false;Appl... 阅读全文
posted @ 2009-08-18 14:59 oraclejava 阅读(605) 评论(0) 推荐(0)
摘要:窗体嵌套   经验丰富的Visual Basic开发者知道多文档界面(MDI)应用程序能够包含子窗体,那些子窗体由MDI父窗体管理。但是如果没有MDI的能力你怎样实现包含嵌套窗体?例如一个MDI子窗体也可能需要包含另一个窗体。  有时能够使用用户控件(UserControl)实现这种功能,但是如果你真的需要把一个窗体嵌套进另一个窗体,有多种方法可以实现。窗体衍生自Control类,这意味着它能被放... 阅读全文
posted @ 2009-08-18 14:58 oraclejava 阅读(479) 评论(0) 推荐(0)
摘要:已知有一个XML文件(bookstore.xml)如下:<?xml version="1.0" encoding="gb2312"?><bookstore> <book genre="fantasy" ISBN="2-3631-4"> <title>Oberon's Legacy</title> <author>Corets,... 阅读全文
posted @ 2009-08-18 14:57 oraclejava 阅读(236) 评论(0) 推荐(0)
摘要:C#追加文件StreamWriter sw = File.AppendText(Server.MapPath(".")+"\\myText.txt");sw.WriteLine("追逐理想");sw.WriteLine("kzlll");sw.WriteLine(".NET笔记");sw.Flush();sw.Close();C#拷贝文件string OrignFile,NewFile;Orign... 阅读全文
posted @ 2009-08-18 14:57 oraclejava 阅读(168) 评论(0) 推荐(0)
摘要:public ArrayList al = new ArrayList();//定义存储文件和文件夹名的数组 public int aaa = 0;//定义标志位参数,递归时判断该参数,若不为0则非第一次递归 public void GetAllDirList(string strBaseDir) { DirectoryInfo di = new DirectoryInfo(strBaseDir)... 阅读全文
posted @ 2009-08-18 14:55 oraclejava 阅读(162) 评论(0) 推荐(0)
摘要:经常可以看到这样的程序,点了关闭按扭后程序并没有关闭,而是最小化到了系统拖盘处,就像网易泡泡,MSN之类的程序。实现这个其实很简单,捕捉窗体关闭时的消息就可以了。代码如下:protected override void WndProc(ref Message m){const int WM_SYSCOMMAND = 0x0112;const int SC_CLOSE = 0xF060;if (m.... 阅读全文
posted @ 2009-08-18 14:53 oraclejava 阅读(198) 评论(0) 推荐(0)
摘要:原来一直是为每个文本框的KeyPress增加: if(e.KeyChar = '\r') SendKeys.Send("{TAB}");最近想想,其实有更简单的方法,把Form的KeyPreView设为true,然后在Form的KeyPress中增加下列代码即可: if (e.KeyChar == '\r') this.SelectNextControl(this.ActiveControl, t... 阅读全文
posted @ 2009-08-18 14:53 oraclejava 阅读(105) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using Microsoft.Win32;namespace Reg4U{ pub... 阅读全文
posted @ 2009-08-18 14:52 oraclejava 阅读(394) 评论(0) 推荐(0)
摘要:1、如何在多行TextBox中写入文本时实现换行? 由于Windows系统中,回车符需两上字符。因此方法是使用\r\n标记,如Label="Calculation "+":.......SUM\r\n"; textBox.AppendText(Label);   另外还有一个办法是用Environment.Newline的方法,可以兼容Windows和Linux系统。2、如何在多行TextBox中... 阅读全文
posted @ 2009-08-18 14:52 oraclejava 阅读(209) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;namespace Log{class LogWirter{/// <summary>/// 事件源名称/// </summary>private string eventSourceName;Ev... 阅读全文
posted @ 2009-08-18 14:51 oraclejava 阅读(122) 评论(0) 推荐(0)
摘要:Microsoft.Win32.RegistryKeykey=Microsoft.Win32.Registry.CurrentUser; Microsoft.Win32.RegistryKeykey1=key.CreateSubKey"Software\Microsoft\Windows\CurrentVersion\Policies\System");key1.SetValue("Disable... 阅读全文
posted @ 2009-08-18 14:50 oraclejava 阅读(489) 评论(0) 推荐(0)
摘要:1.将窗体的属性KeyPrieview设置为true2.在窗体KeyDown事件中加如下代码private void FormVali_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { //屏掉alt+f4 if ((e.KeyCode == Keys.F4)&&(e.Alt == true)) { e.Ha... 阅读全文
posted @ 2009-08-18 14:50 oraclejava 阅读(203) 评论(0) 推荐(0)
摘要:public int[] getRandomNum(int num,int minValue,int maxValue){ Random ra=new Random(unchecked((int)DateTime.Now.Ticks)); int[] arrNum=new int[num]; redo: int tmp=0; for (int i=0;i<=num-1;i++) { tmp=... 阅读全文
posted @ 2009-08-18 14:49 oraclejava 阅读(849) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 下一页