合并表格(Table)单元格

来源:互联网 发布:淘宝购物返利那个高 编辑:程序博客网 时间:2024/04/30 02:24
Imports ZwSoft.ZwCAD.Runtime
Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput


Public Class Class1
    <CommandMethod("MergeCells")> _
    Public Sub MergeCells()
        Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ZcDB As Database = ZcDoc.Database
        Dim ZcEd As Editor = ZcDoc.Editor


        Dim peo As New PromptEntityOptions(vbLf & "Select a table to merge!")
        peo.SetRejectMessage(vbLf & "Must be a table!")
        peo.AddAllowedClass(GetType(Table), True)


        Dim per As PromptEntityResult = ZcEd.GetEntity(peo)
        If per.Status <> PromptStatus.OK Then
            Return
        End If




        Using ZcTrans As Transaction = ZcDB.TransactionManager.StartTransaction()
            Dim tbl As Table = DirectCast(ZcTrans.GetObject(per.ObjectId, OpenMode.ForWrite), Table)
            Dim columns As Int16 = tbl.NumColumns
            tbl.MergeCells(New TableRegion(0, 0, 0, columns - 1))


            ZcTrans.Commit()
        End Using
    End Sub
End Class
0 0
原创粉丝点击