SPREAD for Windows Forms 下箭头追加行
''' <summary> ''' 下矢印の動作クラス ''' </summary> ''' <remarks></remarks> Public Class DownArrowActionDouble ' Actionクラスを継承したサブクラスを作成します Inherits FarPoint.Win.Spread.Action Public Event FormartRow( ByVal sender As Object , ByVal e As FormatRowEventArgs) Public Event CheckRow( ByVal sender As Object , ByVal e As System.ComponentModel.CancelEventArgs) Public Event LeaveCellArrow( ByVal sender As Object , ByVal e As FarPoint.Win.Spread.LeaveCellEventArgs) Public Overrides Sub PerformAction( ByVal sender As Object ) If TypeOf sender Is FarPoint.Win.Spread.SpreadView Then ' アクティブシートを取得します Dim spread As FarPoint.Win.Spread.SpreadView = CType (sender, FarPoint.Win.Spread.SpreadView) Dim sheet As FarPoint.Win.Spread.SheetView = spread.Sheets(spread.ActiveSheetIndex) ' アクティブセルの行列インデックスを取得します Dim Row As Integer = sheet.ActiveRowIndex Dim Col As Integer = sheet.ActiveColumnIndex Dim EvenRow As Integer Dim OddROw As Integer If Row Mod 2 = 0 Then EvenRow = Row OddROw = Row + 1 Else EvenRow = Row - 1 OddROw = Row End If ' 移動先のセルの行列インデックス用変数を宣言します Dim NewRow As Integer Dim NewColumn As Integer Dim isAddRow As Boolean isAddRow = (Row = sheet.RowCount - 1 OrElse (Row = sheet.RowCount - 2 And sheet.Cells(Row + 1, Col).Locked = True )) Dim isMoveNext As Boolean isMoveNext = True Dim e As New System.ComponentModel.CancelEventArgs If Row = OddROw OrElse (Row = EvenRow And sheet.Cells(Row + 1, Col).Locked = True ) Then RaiseEvent CheckRow( Me , e) End If isMoveNext = Not e.Cancel If isAddRow And e.Cancel = False Then sheet.RowCount = sheet.RowCount + 2 RaiseEvent FormartRow( Me , New FormatRowEventArgs(sheet.RowCount - 2, Col)) End If If isMoveNext Then NewRow = Row For i As Integer = Row + 1 To sheet.RowCount - 1 If sheet.Cells(i, Col).Locked = False Then NewRow = i Exit For End If Next NewColumn = Col End If ' 移動先のセルがシート上に存在する場合 If isMoveNext = True And NewRow < sheet.RowCount And NewColumn < sheet.ColumnCount Then Dim ss1 As FarPoint.Win.Spread.SpreadView = spread.GetRootWorkbook RaiseEvent LeaveCellArrow(spread, New FarPoint.Win.Spread.LeaveCellEventArgs(ss1, Row, Col, NewRow, NewColumn)) ' アクティブセルを設定します sheet.SetActiveCell(NewRow, NewColumn) spread.ShowActiveCell(FarPoint.Win.Spread.VerticalPosition.Nearest, FarPoint.Win.Spread.HorizontalPosition.Nearest) End If End If End Sub End Class Public Class CheckRowEventArgs Inherits System.ComponentModel.CancelEventArgs Dim m_IsBlankRow As Boolean Public Property IsBlankRow() As Boolean Get Return m_IsBlankRow End Get Set ( ByVal value As Boolean ) m_IsBlankRow = value End Set End Property End Class Public Class FormatRowEventArgs Inherits EventArgs Public Sub New ( ByVal fRow As Integer , ByVal fCol As Integer ) m_FormatRow = fRow m_FormatCol = fCol End Sub Dim m_FormatRow As Integer Public Property FormatRow() As Integer Get Return m_FormatRow End Get Set ( ByVal value As Integer ) m_FormatRow = value End Set End Property Dim m_FormatCol As Integer Public Property FormatCol() As Integer Get Return m_FormatCol End Get Set ( ByVal value As Integer ) m_FormatCol = value End Set End Property End Class |
' アクションをマッピングします Dim am As FarPoint.Win.Spread.ActionMap = ssBody.GetActionMap() Dim ac As New DownArrowActionDouble() AddHandler ac.CheckRow, AddressOf FpSpead1_CheckRow AddHandler ac.FormartRow, AddressOf FpSpead1_FormartRow AddHandler ac.LeaveCellArrow, AddressOf ssBodyFpSpead1_LeaveCell am.Put("CustomAction", ac) im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Down, Keys.None), "CustomAction") Private Sub FpSpead1_CheckRow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) End Sub Private Sub FpSpead1_FormartRow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) End Sub Private Sub FpSpead1_LeaveCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.LeaveCellEventArgs) End Sub
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
2008-08-22 【Visual Studio】Task List的用法
2008-08-22 【FAQ】「この Web ページがクリップボードへアクセスするのを許可しますか?」というダイアログボックスが表示される
2007-08-22 【Excel】取括号之间的数值