2016-11-25 25 views
0

我的標題中的行顯示了我必須編寫命令的方式,因此沒有編輯器錯誤,但是這種方式什麼也不做。使用richTextBox1。 MS顯示此下面爲正確的格式C#EditingCommands.MoveDownByLine.Execute(rTB,null);

RichTextBox rTB = new RichTextBox(); 

EditingCommands.MoveDownByLine.Execute(null,rTB); 

如果我輸入上面的進線編輯,我得到這些錯誤

錯誤錯誤2參數2:不能從 「系統轉換。 Windows.Forms.RichTextBox'到 'System.Windows.IInputElement'C:\ Users \ Brock \ documents \ visual studio 2013 \ Projects \ PlayListRandomizer \ PlayListRandomizer \ Form1.cs 284 65 PlayListRandomizer

錯誤1爲 最好重載方法匹配 'System.Windows.Input.RoutedCommand.Execute(對象, System.Windows.IInputElement)' 具有一些無效 參數C:\用戶\布洛克\文件\視覺工作室 2013 \ Projects \ PlayListRandomizer \ PlayListRandomizer \ Form1.cs 284 21 PlayListRandomizer

某種視覺工作室的東西,我失蹤了?

回答

0

EditingCommands...Execute()調用IInputElement接口,它是WPF的一部分。您應該使用WPF System.Windows.Controls.RichTextBox,而不是Windows窗體System.Windows.Forms.TextBox

您可以在您的表單中創建一個ElementHost,例如yourElementHost,然後添加WPF RichTextBox。這樣的事情:

 System.Windows.Controls.RichTextBox rTb = new System.Windows.Controls.RichTextBox(); 
     yourElementHost.Child = rTb; 
+0

哇這麼多要學習,謝謝,我會閱讀WPF,並嘗試擴大我的視野。 –