回复 1楼xingaoyang的帖子
Table 自适应宽度需要手动计算:
- Private Sub MenuItem5_Click(sender As Object, e As EventArgs) Handles MenuItem5.Click
- Me.TextControl1.Tables.Add(2, 2, 111)
- End Sub
- Private Sub MenuItem6_Click(sender As Object, e As EventArgs) Handles MenuItem6.Click
- Dim t As TXTextControl.Table
- t = Me.TextControl1.Tables.GetItem(111)
- t.Columns.Remove()
- resizeTable(111)
- End Sub
- Private Sub resizeTable(ByVal tableID As Integer)
- Dim columns As Integer = TextControl1.Tables.GetItem(tableID).Columns.Count
- Dim rows As Integer = TextControl1.Tables.GetItem(tableID).Rows.Count
- For i As Integer = 1 To rows
- Dim curWidth As Integer = 0
- For e As Integer = 1 To columns
- curWidth += TextControl1.Tables.GetItem(tableID).Cells.GetItem(i, e).Width()
- Next
- Dim txWidth As Integer = TextControl1.Width * 15 ' 1/100 inch to Twips
- Dim percentageDelta As Double = (txWidth / curWidth) ' get the difference
- For e As Integer = 1 To columns
- TextControl1.Tables.GetItem(tableID).Cells.GetItem(i, e).Width = TextControl1.Tables.GetItem(tableID).Cells.GetItem(i, e).Width * percentageDelta
- Next
- Next
- End Sub
复制代码 |