摘要: 什么是数据绑定(译) 此篇译文是针对.NET 2.0中的WinForm数据绑定 从一个Windows窗体的角度来看,“数据绑定”是一种把数据绑定到一种用户界面元素(控件)的通用机制。在Windows窗体中有两种数据绑定类型:简单绑定和复杂绑定。 简单绑定 简单绑定是将一个用户界面元素(控件)的属性绑定到一个类型(对象)实例上的某个属性的方法。例如,如果一个开发者有一个Customer类型的... 阅读全文
posted @ 2008-07-28 12:53 浪子の无悔 阅读(1420) 评论(0) 推荐(0) 编辑
摘要: /// /// 讀取SQL Server數據,使用DataSet /// private void DataSerConnection() { try { // 1、 /* * 使用SqlConnection连... 阅读全文
posted @ 2008-07-28 12:52 浪子の无悔 阅读(2553) 评论(0) 推荐(0) 编辑
摘要: 設定表中欄位的默認值... 兩表合並 設定表中欄位的默認值 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> //當新增時,設定欄位的默認值 //定義表 Data... 阅读全文
posted @ 2008-07-28 12:51 浪子の无悔 阅读(994) 评论(0) 推荐(0) 编辑
摘要: 1、設置DataGridView的欄位填充整個顯示區 2、調整欄位顯示位置到最後 3、設定控件的欄位自動調整大小 4、設定DataGridView中欄位的寬度 5、得到DataGridView 當前行的位置 設置DataGridView的欄位填充整個顯示區 Code highlighting produced by Actipro CodeHighlighter (freeware)... 阅读全文
posted @ 2008-07-28 12:51 浪子の无悔 阅读(1915) 评论(0) 推荐(1) 编辑
摘要: 最近因需要,做一個記錄程序運行時間的代碼,並計算耗時,以便於測試程序運行速度。 原理: 被測程序之間定義兩個記錄點。第一個記錄點記錄開始,第二個記錄點記錄結束,得出耗時,保存到文件。這兩個記錄點用標志參數來對應。 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHigh... 阅读全文
posted @ 2008-07-28 12:48 浪子の无悔 阅读(583) 评论(0) 推荐(0) 编辑
摘要: using System.Runtime.InteropServices; [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, in... 阅读全文
posted @ 2008-07-28 12:47 浪子の无悔 阅读(341) 评论(2) 推荐(1) 编辑
摘要: 程序完成後,要對其進行測試。我做一個記錄時間的程序,便於測試。 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> #region 記錄時間 測試使用 /// /// 得到當前時間 ///... 阅读全文
posted @ 2008-07-28 12:35 浪子の无悔 阅读(536) 评论(0) 推荐(0) 编辑
摘要: 設置當子窗體的的大小小於主窗體時,自動調整大小 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> //soctt 20070827 窗體大小改變事件 this.SizeChanged += new EventHandler(F... 阅读全文
posted @ 2008-07-28 12:33 浪子の无悔 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 我分別編寫了主窗題和子窗體的Closing事件,可當關閉主窗體時,同時也觸發了子窗體的Closing事件。這個讓我很頭疼。 不過我還是找到了解決方法。即在子窗體中加入一個 ”e.CloseReason“ 的事件判斷。 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighligh... 阅读全文
posted @ 2008-07-28 12:33 浪子の无悔 阅读(380) 评论(0) 推荐(0) 编辑
摘要: //子表單啟動或關閉事件 this.MdiChildActivate += new EventHandler(FMzMain_MdiChildActivate); Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> private... 阅读全文
posted @ 2008-07-28 12:32 浪子の无悔 阅读(282) 评论(0) 推荐(0) 编辑
摘要: //定義右鍵 ToolStripMenuItem DeletePhraseMe = new ToolStripMenuItem(); DeletePhraseMe.Name = "DeleteBookMark"; DeletePhraseMe.Text = "刪除詞庫"; //定義右鍵事件 ... 阅读全文
posted @ 2008-07-28 12:31 浪子の无悔 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 設置控件的標準顏色類: System.Drawing.SystemColors類 0到9之間數字的ASCII值: 0到9之間數字的ASCII值是48到57,所以就保證字符在這個範圍內。ASCII值8表示退格鍵。 控件的操作無效 KeyPressEventArgs的Handled屬性設置為True,告訴控件不就對字符進行任何操作。 如得到ToolStrip中的子控件 ... 阅读全文
posted @ 2008-07-28 12:31 浪子の无悔 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 剛剛學習了同事編寫的在窗體中打開圖片的代碼,自己也試著做了一例子,以利於學習。 例子如下: 在下列圖片框中雙擊PictureBox插入圖片,並下圖片下方顯示圖片信息。如下圖結果。 代碼如下: Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -... 阅读全文
posted @ 2008-07-28 12:30 浪子の无悔 阅读(2003) 评论(1) 推荐(0) 编辑
摘要: 當我們新建了一個windows窗體應用程序后,單擊運行,后Visual Studo 2005如何顯示窗體的呢?當有多個窗體時,又如何判斷要顯示的窗體呢? 仔細觀察「解決方案資源管理器時」,你會發殃一個名為Program.cs的文件。「查看代碼」后,其中最關鍵的語句是: Code highlighting produced by Actipro CodeHighlighter (freeware... 阅读全文
posted @ 2008-07-28 12:29 浪子の无悔 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 方法: 一、調用窗體FormClosing事件 二、在事件方法中編寫提示代碼 1、調用窗體FormClosing事件 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> //窗體的Closing事件,窗體關閉之前... 阅读全文
posted @ 2008-07-28 12:29 浪子の无悔 阅读(760) 评论(0) 推荐(0) 编辑
摘要: //獲得桌面路徑 string filder = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); Environment:提供有關目前環境和平台的資訊,以及操作的方法。 Environment.SpecialFolder:提供系統特殊文件夾目錄,其成員如下: ... 阅读全文
posted @ 2008-07-28 12:28 浪子の无悔 阅读(583) 评论(0) 推荐(0) 编辑
摘要: 方法: 1、創建一個菜單項數組。 2、在數組中增加菜單項 3、創建一個彈出式引用菜單 4、將菜單與菜單項加入到彈出式引用菜單中 5、將控件的ContextMenuStrip屬性設置成彈出菜單 如下例: 例1: Code highlighting produced by Actipro CodeHighlighter (freeware) http... 阅读全文
posted @ 2008-07-28 12:27 浪子の无悔 阅读(3050) 评论(0) 推荐(0) 编辑
摘要: # 中如何打印文件呢,本例將用一個實例(打印一些字符)作說明。 本例過程為: 1. 調用打印對話框 2. 啟動打印程序 3. 建立打印事件 4. 建立StringBuilder 5. 將打印內容寫入建立StringBuilder 6. 繪制打印內容(即打印) Code highlighting produced by Actipro CodeHighlighter (freeware) ht... 阅读全文
posted @ 2008-07-28 12:27 浪子の无悔 阅读(1184) 评论(0) 推荐(0) 编辑
摘要: 先了解一下StatusStrip:首選StatusStrip是Form中的一個控件,同時也是一個大的控件,其中含有許多子控件,這些子控件存放在控件群中。 這樣我們要使用StatusStrip時,首先要定義StatusStrip,然后定義ToolStrip控件,再次定義ToolStrip控件群,第三將ToolStrip控件加入到控件群中,第四將控件群加入到StatusStrip中,最后要將Statu... 阅读全文
posted @ 2008-07-28 12:26 浪子の无悔 阅读(5559) 评论(0) 推荐(0) 编辑
摘要: 1.最小化 WindowState = FormWindowState.Minimized; //最小化时隐藏窗体 this.Visible=false; 2.最大化 WindowState == FormWindowState.Maximized; 3.还原为正常 WindowState == FormWindowState.Normal; 4.在托盘显示 打开 VS.net的工具箱,然后... 阅读全文
posted @ 2008-07-28 12:25 浪子の无悔 阅读(599) 评论(0) 推荐(0) 编辑