本帖最后由 hessen 于 2019-8-14 17:59 编辑
菜单栏添加自定义按钮
功能说明:
在填报、修改、查阅模板时,顶部的菜单栏添加一个自定义按钮用于执行各项操作。
支持版本:
企业版7.0以上
效果:
代码:
- Imports SpreadsheetGear
- Imports C1.Silverlight
- Imports C1.Silverlight.C1MessageBoxButton
- Imports C1.Silverlight.C1MessageBoxIcon
- Imports Newtonsoft.Json
- Imports Newtonsoft.Json.Linq
- Imports System.Windows.forms
- Namespace ExcelViewVBDotnet
- Public Class StandardInterface
- '预留位置1
- '预留位置2
- Dim EV As SpreadsheetGear.Windows.Co**ols.WorkbookView,AW As SpreadsheetGear.IWorkbook,Range As SpreadsheetGear.IRange
- Dim CF,VW As Object
- Dim TS As StackPanel
- Public Sub Workbook_Open(OldRoot As Object,NewRoot As Object,Excel As SpreadsheetGear.Windows.Co**ols.WorkbookView)
- EV = Excel
- Excel.GetLock()
- AW = Excel.ActiveWorkbook
- Range = AW.ActiveWorksheet.Range
- Excel.ReleaseLock()
- CF = OldRoot.Children(1) '绑定工具条触发,不能测试运行
- TS = CType(OldRoot.Children(5),StackPanel)
- '工具条添加第一个按钮
- Dim BT1 As New Button
- BT1.Name = "BT_AN1" '按钮名,不能与其他按钮名称重复,下同。
- BT1.Content = "第一个按钮" '按钮显示的名称,自定义写入欲显示的名称。下同
- BT1.Margin= New Thickness(0, 2, 0, 2)
- BT1.Padding= New Thickness(13, 3, 13, 3)
- BT1.Style=CType(Application.Current.Resources("ButtonStyle3"),style)
- BT1.Foreground = CType(Application.Current.Resources("Foreground1"),System.Windows.Media.Brush)
- TS.Children.Insert(17, BT1) '插入按钮的位置,多个按钮时顺序往下排
-
- End Sub'打开时执行事件
- Public Sub RangeSelection(sender As Object,e As SpreadsheetGear.Windows.Co**ols.RangeSelectionChangedEventArgs)
- End Sub'单元格选择后执行的事件
- Public Sub RangeChanged(sender As Object,e As SpreadsheetGear.Windows.Co**ols.RangeChangedEventArgs)
- End Sub'单元格编辑完成后执行事件
- Public Sub ButtunClick(sender As Object,e As SpreadsheetGear.Windows.Co**ols.ShapeActionEventArgs)
- End Sub'按钮/标签点击事件
- Public Sub FollowHyperlink(sender As Object)
- End Sub '暂不支持
- End Class
- ' 注:除事件字眼下可以自定义代码外的所有代码不允许改动,否则编译将有可能失败。
- End Namespace
复制代码
|
hessen