翻譯|使用教程|編輯:況魚杰|2019-07-10 10:05:37.007|閱讀 498 次
概述:本教程介紹如何創(chuàng)建TX Text Control .NET for Windows Forms的功能區(qū)應(yīng)用程序:添加上下文功能區(qū)的選項(xiàng)卡。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
TX Text Control .NET for Windows Forms 是一套功能豐富的文字處理控件,它以可重復(fù)使用控件的形式為開發(fā)人員提供了Word中常用的文字處理功能,對(duì)于需要強(qiáng)大且靈活的文檔處理能力的應(yīng)用程序而言,是理想的選擇。
點(diǎn)擊下載 TX Text Control .NET for Windows Forms X17試用版
本教程介紹如何創(chuàng)建TX Text Control .NET for Windows Forms的功能區(qū)應(yīng)用程序這部分教程將會(huì)分為三個(gè)部分,本章是第二部分,將會(huì)介紹如何添加上下文功能區(qū)的選項(xiàng)卡(點(diǎn)擊上、下可獲得其他教程)。
在此步驟中,添加并連接用于表格和框架布局任務(wù)的上下文功能區(qū)選項(xiàng)卡
在表單上,通過單擊藍(lán)色File選項(xiàng)卡標(biāo)題選擇功能區(qū)控件,以單擊功能區(qū)控件右上角的智能標(biāo)記。單擊Quick Access Toolbar 將表單轉(zhuǎn)換為Windows.Forms.Ribbon.RibbonForm。
再次選擇功能區(qū)控件,方法是單擊藍(lán)色的 File 選項(xiàng)卡標(biāo)題,然后在Properties 窗口中找到ContextualTabGroups屬性。
單擊ContextualTabGroups屬性的(Collection)值列中的省略號(hào)按鈕,打開ContextualTabGroup集合編輯器。
在Collection Editor中,單擊Add以添加新的Windows.Forms.Ribbon.ContextualTabGroup,將此組命名為m_grpTableTools,將Header屬性設(shè)置為Table Tools并選擇BackColor。
在m_grpTableTools屬性中找到ContextualTabs屬性,然后單擊(Collection)值列中的省略號(hào)按鈕以打開RibbonTab集合編輯器。點(diǎn)擊Add按鈕,然后單擊RibbonTableLayoutTab項(xiàng).單擊OK關(guān)閉對(duì)話框。
重復(fù)步驟4并將此新組命名為m_grpFrameTools,將Header屬性設(shè)置為Frame Tools并選擇另一個(gè)BackColor。
找到ContextualTabs屬性,然后單擊(Collection)值列中的省略號(hào)按鈕以打開RibbonTab集合編輯器。與步驟5中一樣,打開 Add按鈕并單擊 RibbonFrameLayoutTab項(xiàng),最后單擊OK關(guān)閉對(duì)話框。
在 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
構(gòu)建并啟動(dòng)應(yīng)用程序。 使用Insert功能區(qū)選項(xiàng)卡中的Table插入表格。將輸入位置設(shè)置到表中以便上下文查看表工具選項(xiàng)卡。
創(chuàng)建TX Text Control .NET for Windows Forms功能區(qū)應(yīng)用程序的教程就快完了,你還沒有開始實(shí)際操作嗎?趕緊動(dòng)手試試吧!也希望持續(xù)關(guān)注我們的TX Text Control .NET系列教程。
想要了解更多有關(guān)慧都的資訊,請點(diǎn)擊,或者關(guān)注慧聚IT微信公眾號(hào) ???
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: