Setting Table Margins

Setting Table Margins

Anonymous
Not applicable
1,339 Views
4 Replies
Message 1 of 5

Setting Table Margins

Anonymous
Not applicable

I am trying to set my tables margins. My line to do that is:

 

atsHeadTable.SetMargin(CellMargins.Left, 0.03, RowType.DataRow)

 

But I get an error when doing this.  I think I have the stylename in the command wrong.  What do I put in there?

 

I also used the command:

 

MyTable.Cells(0, 0).Borders.Horizontal.Margin = 0.03

 

This works but I have to set it for each cell.

0 Likes
1,340 Views
4 Replies
Replies (4)
Message 2 of 5

Hallex
Advisor
Advisor

Try to set to exact size the height of the table before

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 3 of 5

Hallex
Advisor
Advisor

Here is a quick example

        Public Shared Sub SetMarginsToTable()
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Using tr As Autodesk.AutoCAD.DatabaseServices.Transaction = doc.Database.TransactionManager.StartTransaction()
                Dim peo As PromptEntityResult = ed.GetEntity(vbCr & "Select table >>")
                Dim ent As Entity = CType(tr.GetObject(peo.ObjectId, OpenMode.ForWrite), Entity)
                Dim tb As Table = TryCast(ent, Table)
                'particular cells only:
                'Dim row As Integer = 2, column = 1
                'tb.SetMargin(row, column, CellMargins.Left, 0.03)
                'entire tatble:
                tb.HorizontalCellMargin = 0.075
                tb.VerticalCellMargin = 0.03
                tr.Commit()
                ''check changes
                MsgBox(String.Format("Vertical margins: {0}" & vbCr & "Horizontal margins: {1}", tb.VerticalCellMargin, tb.HorizontalCellMargin))
            End Using
        End Sub

 

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks that helped.  I did try that when I started to make my program and received an error. The error must have came from somewhere else.  This now works.

0 Likes
Message 5 of 5

Hallex
Advisor
Advisor

You're welcome

Cheers 🙂

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes