1.應用軟體:vs2010
2. 程式完成的功能:
2.1 在richtextbox中載入xaml檔案
2.2 設定滾動速度
2.3 滾動
2.4 滑鼠雙擊停止滾動
3. 程式用到的控制項:richtextbox,button,label,textbox
4.程式的實現
4.1 控制項布局
wpf中布局好的控制項圖如下:
4.2 實現控制項的響應函式
**
namespacefreescroll
//載入檔案
private
void
load_click(
object
sender, routedeventargs e)
openfiledialog opendialog
=new
openfiledialog ();
if(opendialog.showdialog()
==true)}
}//實現滾動
private
void
scroll_click(
object
sender, routedeventargs e)
inttimeinterval;
if(textbox1.text
!=""
) else
} else
}void
timer_tick(
object
sender, eventargs e)
//滑鼠雙擊停止滾動
private
void
richtextbox1_mousedoubleclick(
object
sender, mousebuttoneventargs e)
double
tmp =0
;dispatchertimer timer
=new
dispatchertimer(); }}
RichTextBox的翻頁演算法
system.runtime.interopservices.dllimport user32.dll public static extern int sendmessage intptr hwnd,int wmsg,int wparam,int lparam private void paged...
相互關聯的RichTextbox
using system.windows.forms public class synchronizedscrollrichtextbox system.windows.forms.richtextbox public const int wm vscroll 0x115 public const ...
C 檢測RichTextBox 實際行數
碰到的問題 我們的程式需要做文字的行數控制,也就是當文字輸入至指定行數時,再增加行數就會出現警告,不能再進行輸入了。最初的解決方法 因為richtextbox本身帶有lines屬性,所以開始的時候打算直接採用這個屬性,然後在textchanged事件中進行行數控制。但是實際執行時發現這種方法不行。m...