Time of Update: 2018-12-06
雖然有 TabControl控制項, 但是為了減少主表單的代碼量, 可以將部分分頁的功能模組放置於一個 Form 中, 當調用時, 直接把這個 Form嵌入到一個 Panel中即可.樣本如下:要嵌入的 Form:
Time of Update: 2018-12-06
源碼下載:http://dotnet.5d6d.com/thread-471-1-1.html正常情況下,.Net內建的ListBox是無法進行編輯的,欲讓它可編輯,我們可添加一個隱藏的文本編輯框,當雙擊項的時候顯示編輯框,更新項內容後隱藏編輯框即可。欲調整ListBox每個項的高度,ListBox有一個內建屬性ItemHeight,於是我們很自然的就設這個屬性值,結果卻發現改不動,改後又返回預設值12,後面才發現要使該屬性值有效更改,必須將DrawMode屬性設為OwnerDrawFixed,
Time of Update: 2018-12-06
無法在屬性面版裡直接修改,可以在Paint事件裡重畫。private void panel1_Paint(object sender, PaintEventArgs e){ ControlPaint.DrawBorder(e.Graphics, this.panel1.ClientRectangle, Color.LightSeaGreen,//7f9db9
Time of Update: 2018-12-06
調用Windows
Time of Update: 2018-12-06
以前一直做web開發,基本上是加<br/>或者css控制word-break:break-all;word-wrap:break-word;Windows中Label控制項是把Label的AutoSize屬性設為False,這樣就可以拖放了。記錄一下。WinForm很多朋友都會在開發WinForm中遇到Label要顯示的內容太長,但卻不能換行的問題.這裡我總結了幾種方法,供大家參考:
Time of Update: 2018-12-06
一般認為:foreach (object obj in
Time of Update: 2018-12-06
如果你希望使用者按F1彈出chm協助,代碼如下:private void FrmMain_Load(object sender, EventArgs e){ this.KeyPreview = true;//擷取或設定一個值,該值指示在將鍵事件傳遞到具有焦點的控制項前,表單是否將接收此鍵事件。}private void FrmMain_KeyUp(object sender, KeyEventArgs e){ if (Keys.F1 == e.KeyCode) {
Time of Update: 2018-12-06
Revit二次開發 - C#程式員的佳好選擇 最近對winForm研究多一些,收錄在分類裡,不斷更新。http://www.cnblogs.com/greatverve/category/267062.html C#的WinForm源碼真的是太少了。我找了些不錯的,分享一下。水晶報表入門樣本(C# WinForm)http://revit.5d6d.com/thread-442-1-1.htmlC# 皮膚(WinForm) 下載 http://revit.5d6d.com/thread-45
Time of Update: 2018-12-06
雖然Revit的使用者和開發目前在中國都很少,但是這是個趨勢。未來Revit會在許多方面取代Autocad做CAD二次開發的,在中國也很吃香。但是使用C++難倒了許多人。而Revit二次開發可以使用C#並且上手非常容易。假如你是一個C#程式員,正在確定自己未來的方向,不妨考慮做個Revit二次開發人員。這是我剛剛建立的Revit二次開發論壇http://revit.5d6d.com目前國內還沒有成熟的Revit二次開發產品,我們共同努力吧。
Time of Update: 2018-12-06
Revit二次開發 - C#程式員的佳好選擇 最近對winForm研究多一些,收錄在分類裡,不斷更新。http://www.cnblogs.com/greatverve/category/267062.html 抱歉,gae空間被牆了。我把源碼發到我的論壇http://revit.5d6d.com/ 我發現找winForm源碼的挺多。我找一找把更新一下。開了新帖,不斷更新WinForm源碼:http://www.cnblogs.com/greatverve/archive/2011/04/13/
Time of Update: 2018-12-06
使用"/"運算子實現兩數相除1.當兩個運算元a、b均為Int類型時,結果自動捨棄小數部分,例如:a=11 b=3,a/b=32.當兩個運算元a、b均為Double類型時, 結果是Double類型數,例如:a=11 b=3,a / b=3.66666666666667 若使用Convert.ToInt32進行轉化,結果四捨五入,例如:a=11 b=3,Convert.ToInt32(a /
Time of Update: 2018-12-06
Winform擷取應用程式的當前路徑的方法集合,具體如下,值得收藏//擷取當前進程的完整路徑,包含檔案名稱(進程名)。string str = this.GetType().Assembly.Location;result: X:\xxx\xxx\xxx.exe (.exe檔案所在的目錄+.exe檔案名稱)//擷取新的Process 組件並將其與當前活動的進程關聯的主模組的完整路徑,包含檔案名稱(進程名)。string str = System.Diagnostics.Process.GetCu
Time of Update: 2018-12-06
把檔案或者目錄直接拖放到你的程式上,這種效果使用者體驗不錯。得到拖過來的路徑的代碼:(System.Array)e.Data.GetData(DataFormats.FileDrop)然後你可以根據這些路徑複製粘貼了。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using Syst
Time of Update: 2018-12-06
在項目屬性面版->調試->命令列參數設定。空格分隔。讀取:string[] str = Environment.GetCommandLineArgs();Main函數是C#應用程式的進入點,Main函數可以有四種簽名,分別如下:static void Main()static void Main(string[] args)static int Main()static int Main(string[] args)執行這個函數就是執行應用程式。而這個函數有一個參數string[]
Time of Update: 2018-12-06
程式啟動並執行時候把編號記下來判斷。通過GetForegroundWindow()找到當前啟用的程式。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;using System.Diagnostic
Time of Update: 2018-12-06
完全透明的按鈕,只在滑鼠經過時顯示邊框線。屬性Button.Image設定圖片按鈕,可與背景完美結合。/// <summary>/// 設定透明按鈕樣式/// </summary>private void SetBtnStyle(Button btn){ btn.FlatStyle = FlatStyle.Flat;//樣式 btn.ForeColor = Color.Transparent;//前景 btn.BackColor = Color.Tran
Time of Update: 2018-12-06
這裡假定只有兩級節點,多級方法類似。遍曆節點,根據選中節點文本找到要選中的節點。treeView.SelectedNode =
Time of Update: 2018-12-06
當使用者焦點離開TreeView時,TreeView選中節點仍然高亮,但是顏色太淺,幾乎看不出來。這裡重寫一下DrawMode();可以控制選中節點顏色。TreeView.HideSelection =
Time of Update: 2018-12-06
原理就是在註冊表啟動項裡添加一項。路徑:SOFTWARE\Microsoft\Windows\CurrentVersion\Run或者直接:運行->regedit找到這個路徑添加一項。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using
Time of Update: 2018-12-06
start步驟一:建立類庫項目,建立FirstControl.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms;using System.Drawing;using System.ComponentModel;namespace UcDll{ public class FirstControl : Control