gaishitaibao 你好,
可以获取 table 宽度,在插入后,分别设置 column 宽度从而达到该效果:
- private void Form1_Load(object sender, EventArgs e)
- {
- this.textControl1.Tables.Add(5, 5, 11);
- }
- private void insertColumnToolStripMenuItem_Click(object sender, EventArgs e)
- {
- //获取 Table
- TXTextControl.Table table = textControl1.Tables.GetItem(11);
- //获取 Table 宽度
- int tableWidth = 0;
- foreach (TXTextControl.TableColumn item in table.Columns)
- {
- tableWidth += item.Width;
- }
- //插入列
- table.Columns.Add(TXTextControl.TableAddPosition.After);
- //设置插入之后列宽
- int columnCount = table.Columns.Count;
- int averageColumnWidth = tableWidth / columnCount;
- foreach (TXTextControl.TableColumn item in table.Columns)
- {
- item.Width = averageColumnWidth;
- }
- }
复制代码 |