TX Text Control系列教程—Windows Forms:创建功能区应用程序(中)

本教程介绍如何创建TX Text Control .NET for Windows Forms的功能区应用程序:添加上下文功能区的选项卡。

    TX Text Control .NET for Windows Forms 是一套功能丰富的文字处理控件,它以可重复使用控件的形式为开发人员提供了Word中常用的文字处理功能,对于需要强大且灵活的文档处理能力的应用程序而言,是理想的选择。

  TX Text Control .NET for Windows Forms X17试用版   


    本教程介绍如何创建TX Text Control .NET for Windows Forms的功能区应用程序这部分教程将会分为三个部分,本章是第二部分,将会介绍如何添加上下文功能区的选项卡(点击可获得其他教程)。

在此步骤中,添加并连接用于表格和框架布局任务的上下文功能区选项卡    

  1. 在表单上,通过单击蓝色File选项卡标题选择功能区控件,以单击功能区控件右上角的智能标记。单击Quick Access Toolbar 将表单转换为Windows.Forms.Ribbon.RibbonForm。

  2. 再次选择功能区控件,方法是单击蓝色的 File 选项卡标题,然后在Properties 窗口中找到ContextualTabGroups属性。

    n_winforms_tutorial_ribbon_context_1.png
  3. 在Collection Editor中,单击Add以添加新的Windows.Forms.Ribbon.ContextualTabGroup,将此组命名为m_grpTableTools,将Header属性设置为Table Tools并选择BackColor。             

    n_winforms_tutorial_ribbon_context_2.png
  4. 重复步骤4并将此新组命名为m_grpFrameTools,将Header属性设置为Frame Tools并选择另一个BackColor。                

  5. n_winforms_tutorial_ribbon_context_3.png
  6. 在 Solution Explore中,选择表单Form1并从View主菜单中选择Code。添加以下代码,完整的Form1类代码如下所示:  

    代码-cs                         

    public partial class Form1 : TXTextControl.Windows.Forms.Ribbon.RibbonForm    {    public Form1()    {    InitializeComponent();    textControl1.InputPositionChanged += TextControl1_InputPositionChanged;    textControl1.FrameSelected += TextControl1_FrameSelected;    textControl1.FrameDeselected += TextControl1_FrameDeselected;    textControl1.DrawingActivated += TextControl1_DrawingActivated;    textControl1.DrawingDeselected += TextControl1_DrawingDeselected;    }    private void TextControl1_DrawingDeselected(object sender,    TXTextControl.DataVisualization.DrawingEventArgs e)    {    if ((textControl1.Frames.GetItem() == null) &&    (textControl1.Drawings.GetActivatedItem() == null))    {    m_grpFrameTools.Visible = false;    }    }    private void TextControl1_DrawingActivated(object sender,    TXTextControl.DataVisualization.DrawingEventArgs e)    {    m_grpFrameTools.Visible = true;    }    private void TextControl1_FrameDeselected(object sender,    TXTextControl.FrameEventArgs e)    {    if ((textControl1.Frames.GetItem() == null) &&    (textControl1.Drawings.GetActivatedItem() == null))    {    m_grpFrameTools.Visible = false;    }    }    private void TextControl1_FrameSelected(object sender,    TXTextControl.FrameEventArgs e)    {    m_grpFrameTools.Visible = true;    }    private void TextControl1_InputPositionChanged(object sender, EventArgs e)    {    m_grpTableTools.Visible = textControl1.Tables.GetItem() != null;    }    }

    代码-vb

    Public Partial Class Form1    Inherits TXTextControl.Windows.Forms.Ribbon.RibbonForm    Public Sub New()    InitializeComponent()    AddHandler textControl1.InputPositionChanged, AddressOf TextControl1_InputPositionChanged    AddHandler textControl1.FrameSelected, AddressOf TextControl1_FrameSelected    AddHandler textControl1.FrameDeselected, AddressOf TextControl1_FrameDeselected    AddHandler textControl1.DrawingActivated, AddressOf TextControl1_DrawingActivated    AddHandler textControl1.DrawingDeselected, AddressOf TextControl1_DrawingDeselected    End Sub    Private Sub TextControl1_DrawingDeselected(sender As Object, e As TXTextControl.DataVisualization.DrawingEventArgs)    If (textControl1.Frames.GetItem() Is Nothing) AndAlso (textControl1.Drawings.GetActivatedItem() Is Nothing) Then    m_grpFrameTools.Visible = False    End If    End Sub    Private Sub TextControl1_DrawingActivated(sender As Object, e As TXTextControl.DataVisualization.DrawingEventArgs)    m_grpFrameTools.Visible = True    End Sub    Private Sub TextControl1_FrameDeselected(sender As Object, e As TXTextControl.FrameEventArgs)    If (textControl1.Frames.GetItem() Is Nothing) AndAlso (textControl1.Drawings.GetActivatedItem() Is Nothing) Then    m_grpFrameTools.Visible = False    End If    End Sub    Private Sub TextControl1_FrameSelected(sender As Object, e As TXTextControl.FrameEventArgs)    m_grpFrameTools.Visible = True    End Sub    Private Sub TextControl1_InputPositionChanged(sender As Object, e As EventArgs)    m_grpTableTools.Visible = textControl1.Tables.GetItem() IsNot Nothing    End Sub    End Class
  7. 构建并启动应用程序。使用Insert功能区选项卡中的Table插入表格。将输入位置设置到表中以便上下文查看表工具选项卡。

    n_winforms_tutorial_ribbon_context_4.png

    创建TX Text Control .NET for Windows Forms功能区应用程序的教程就快完了,你还没有开始实际操作吗紧动手试试吧!也希望持续关注我们的TX Text Control .NET系列教程。   


      

    .jpg 

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年6月7日
下一篇 2019年6月7日

相关推荐

发表回复

登录后才能评论