TX Text Control系列教程—Windows Forms:建立功能區應用程序(三)

 

     TX Text Control .NET for Windows Forms 是一套功能豐富的文字處理控件,它以可重複使用控件的形式爲開發人員提供了Word中經常使用的文字處理功能,對於須要強大且靈活的文檔處理能力的應用程序而言,是理想的選擇。函數

 點擊下載 TX Text Control .NET for Windows Forms X17試用版   .net


    本教程介紹如何建立TX Text Control .NET for Windows Forms的功能區應用程序這部分教程將會分爲三個部分,本章是第三部分,將會介紹添加應用程序菜單的過程(點擊可得到前面的教程)。orm

  1. 在Solution Explorer中,選擇Form1表單,而後從View主菜單中選擇Designer。blog

  2. 選擇功能區控件,而後在Properties窗口中找到ApplicationMenuItems屬性。教程

    n_winforms_tutorial_ribbon_context_5.png

  3. 單擊ApplicationMenuItems屬性的(Collection)值列中的省略號按鈕,打開Control Collection Editor。事件

  4. 在Control Collection Editor中,單擊Add以添加新的Windows.Forms.Ribbon.RibbonButton。將此按鈕命名爲m_rbtnLoad,並將Text屬性設置爲Load ....,將名爲m_rbtnSave和Text Save ....添加爲第二個按鈕,而後單擊OK關閉對話框。開發

  5. 在Solution Explorer中,選擇表單Form1並從View主菜單中選擇Code。將另外兩個事件附加到Form1構造函數代碼,以便完整的構造函數代碼以下所示:文檔

    cs:get

    public Form1()    
    {    
    InitializeComponent();    
    textControl1.InputPositionChanged += TextControl1_InputPositionChanged;    
    textControl1.FrameSelected += TextControl1_FrameSelected;    
    textControl1.FrameDeselected += TextControl1_FrameDeselected;    
    textControl1.DrawingActivated += TextControl1_DrawingActivated;    
    textControl1.DrawingDeselected += TextControl1_DrawingDeselected;    
    m_rbtnLoad.Click += M_rbtnLoad_Click;    
    m_rbtnSave.Click += M_rbtnSave_Click;    
    }

    vb:it

    Public Sub New()    
    InitializeComponent()    
    textControl1.InputPositionChanged += TextControl1_InputPositionChanged    
    textControl1.FrameSelected += TextControl1_FrameSelected    
    textControl1.FrameDeselected += TextControl1_FrameDeselected    
    textControl1.DrawingActivated += TextControl1_DrawingActivated    
    textControl1.DrawingDeselected += TextControl1_DrawingDeselected    
    AddHandler m_rbtnLoad.Click, AddressOf M_rbtnLoad_Click    
    AddHandler m_rbtnSave.Click, AddressOf M_rbtnSave_Click    
    End Sub
  6. 在Form構造函數代碼下,添加如下兩個新的事件處理程序方法:

    cs:

    private void M_rbtnSave_Click(object sender, EventArgs e)    
    {    
    textControl1.Save();    
    }    
    private void M_rbtnLoad_Click(object sender, EventArgs e)    
    {    
    textControl1.Load();    
    }

    vb:

    Private Sub M_rbtnSave_Click(sender As Object, e As EventArgs)    
    textControl1.Save()    
    End Sub    
    Private Sub M_rbtnLoad_Click(sender As Object, e As EventArgs)    
    textControl1.Load()    
    End Sub
  7. 構建並啓動應用程序。

    單擊File應用程序菜單時,能夠看到兩個菜單項,用以加載和保存文檔。

n_winforms_tutorial_ribbon_context_6.png

    建立TX Text Control .NET for Windows Forms功能區應用程序的教程就到這裏結束了,趕忙動手試試吧!下一節咱們將會介紹如何建立第一個Windows窗體應用程序,也但願持續關注咱們的TX Text Control .NET系列教程。   

相關文章
相關標籤/搜索