这个例子是实现通过自定义按钮1(Button 1)将明细表里一整列数据复制到目的列,而后再执行保存。
代码如下:
- 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.Controls.WorkbookView,AW As SpreadsheetGear.IWorkbook,Range As SpreadsheetGear.IRange
- Dim CF As TextBox
- Public Sub Workbook_Open(OldRoot As Object,NewRoot As Object,Excel As SpreadsheetGear.Windows.Controls.WorkbookView)
- EV = Excel
- Excel.GetLock()
- AW = Excel.ActiveWorkbook
- Range = AW.ActiveWorksheet.Range
- Excel.ReleaseLock()
- CF = CType(OldRoot.Children(1), TextBox)
- End Sub'打开时执行事件
- Public Sub RangeSelection(sender As Object,e As SpreadsheetGear.Windows.Controls.RangeSelectionChangedEventArgs)
- End Sub'单元格选择后执行的事件
- Public Sub RangeChanged(sender As Object,e As SpreadsheetGear.Windows.Controls.RangeChangedEventArgs)
- End Sub'单元格编辑完成后执行事件
- Public Sub ButtunClick(sender As Object,e As SpreadsheetGear.Windows.Controls.ShapeActionEventArgs)
- aw.WorkbookSet.GetLock()
- If e.Shape.Name = "Button 1" Then
- range("F_5335").Copy(range("F_5337"))
- ' 计时器(避免造成大频率循环造成资源占用)
- Dim XHTimer As DispatcherTimer = New DispatcherTimer
- XHTimer.Interval = New TimeSpan(0, 0, 0, 1, 0) '1秒
- AddHandler XHTimer.Tick, Sub(s1, e1)
- XHTimer.Stop() '停止计时器
- CF.Text = "#保存"
- End Sub
- XHTimer.Start() '开始计时器
- End If
- aw.WorkbookSet.ReleaseLock()
-
- End Sub'按钮/标签点击事件
- Public Sub FollowHyperlink(sender As Object)
- End Sub '暂不支持
- End Class
- ' 注:除事件字眼下可以自定义代码外的所有代码不允许改动,否则编译将有可能失败。
- End Namespace
复制代码 将代码复制到快表VBA中编译就可使用。
F_5335为被复制列,F_5337为目的列。
|
|
hong90342