Time of Update: 2018-12-04
string s = "測試文字,隨便寫一些文字"; foreach (char c in s) { textBox1.AppendText(c.ToString()); int tick = Environment.TickCount; //間隔時間,按你自己喜好,我這裡寫100毫秒 while
Time of Update: 2018-12-04
private void button1_Click(object sender, EventArgs e) { RunWhenStart(false, "mystarton", @"C:/Program Files/UltraEdit/Uedit32.exe"); } /// <summary> /// 開機啟動項 /// </summary> ///
Time of Update: 2018-12-04
//在Form的屬性中要設定 AlowDrop為true private void Form1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetData(DataFormats.FileDrop) != null) { e.Effect = DragDropEffects.Copy; }
Time of Update: 2018-12-04
正常來說,那麼winform是擷取不到EXE的傳回值,這時我所用的方法是把EXE中的值寫到csv檔案中,然後winform去讀取csv private void btnGoodsSelect_Click(object sender, EventArgs e) { ParameterizedThreadStart pts = new ParameterizedThreadStart(RunCommand); Thread
Time of Update: 2018-12-04
[System.Runtime.InteropServices.DllImport("user32.dll ")] public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc); [System.Runtime.InteropServices.DllImport("user32.dll ")] public static extern int GetWindow
Time of Update: 2018-12-04
1. 最簡單的是可以直接用Console.Beep();或者Console.Beep(frequency, duration);可以自訂任意Hz的音頻,和任意時間;不過我在win7的環境下產生的Exe在xp系統下會從主機發出聲音,原因未知;可能是系統不同,編譯後的異常。 2.也可以使用dll類 [DllImport("kernel32.dll")] private static extern int Beep(int dwFreq, int
Time of Update: 2018-12-04
堆排序的主要原理就是利用堆的特點,首先產生最大堆,然後每次取堆的root和最後一個葉子交換,剔除最後葉子。然後再次產生最大堆,迴圈。 /// <summary> /// 堆排序 /// </summary> /// <param name="Myarray"></param> /// <returns></returns> private int[]
Time of Update: 2018-12-04
string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/A.mdb"; OleDbConnection odcConnection = new OleDbConnection(strConn); //2、開啟串連 C#操作Access之按列讀取mdb odcConnection.Open(); //建立SQL查詢
Time of Update: 2018-12-04
在頁面page_load中: int num = 0; for (int i = 0; i < dt_data.Rows.Count; i++) { dgv.Rows.Add(); int n = dgv.Rows.Count - 1; for (int j = 2; j
Time of Update: 2018-12-04
private void Form1_Load(object sender, EventArgs e) { TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks); //擷取目前時間的刻度數 //你的代碼或者其他動作 double dout = 1; for (int i = 1; i <= 10; i++) {
Time of Update: 2018-12-04
[DllImport("User32.dll", EntryPoint = "FindWindow")] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); //添加引用 找到視窗控制代碼 private void button1_Click_1(object sender, EventArgs e) { IntPtr
Time of Update: 2018-12-04
*我也是抄別人的,禁止關閉沒什麼問題,當然只要別在進程管理器裡關就行。呵呵禁止拖動有問題,就是用標題列左邊的表徵圖菜單,是可以拖動表單的。【解決辦法應該是,用this.position來解決吧】 private const int SC_CLOSE = 0xF060; private const int MF_ENABLED = 0x00000000; private const int MF_GRAYED = 0x00000001;
Time of Update: 2018-12-04
private void Form1_MouseClick(object sender, MouseEventArgs e) { System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder(); messageBoxCS.AppendFormat("{0} = {1}", "Button", e.Button);
Time of Update: 2018-12-04
網路編程真麻煩,只能這麼死記硬背了. private void myButton1_Click(object sender, EventArgs e) { //建立串連,發送訊息 System.Net.Sockets.TcpClient tcp = new System.Net.Sockets.TcpClient("192.168.24.23", 8051); string signal = "create
Time of Update: 2018-12-04
private void myButton2_Click(object sender, EventArgs e) { //Execute("net user zero 0571m.com /add", 0); string output = Execute("ver" + "/r/n", 0); Console.WriteLine(output); } public static
Time of Update: 2018-12-04
C#遍曆指定檔案夾中的所有檔案 DirectoryInfo TheFolder=new DirectoryInfo(folderFullName);//遍曆檔案夾foreach(DirectoryInfo NextFolder in TheFolder.GetDirectories()) this.listBox1.Items.Add(NextFolder.Name);//遍曆檔案foreach(FileInfo NextFile in TheFolder.GetFiles())
Time of Update: 2018-12-04
包括多個優盤。 #region USB Device Check start //====================================================================================== //Search the USB device public const int WM_DEVICECHANGE = 0x219; public const int
Time of Update: 2018-12-04
//http://dotnet.chinaitlab.com/List_233.html private void button4_Click(object sender, EventArgs e) { //預覽功能,需要增加一個控制項:ThePrintDocument string strText = richTextBox1.Text;
Time of Update: 2018-12-04
取項目名稱: static string AppName() { string fullstr = Assembly.GetExecutingAssembly().FullName; return fullstr.Substring(0, fullstr.IndexOf(",")); } 根據表單上的控制項名稱取控制項 public static Control
Time of Update: 2018-12-04
雖然,對於N個TIMER類不瞭解,對於TICK 和 E.....的也不瞭解, 但這段代碼管用,就這樣吧。 Timer t = new Timer(); int labelX; int labelY; private void Form1_Load(object sender, EventArgs e) { string news1 = "434534"; label1.Text =