表格插入表格的bug
现在遇到一个问题,我有一个生成的表格,这个表格在非表格区域插入是正常的,但是在一个表格的某个Cell里面插入,最后面一行无法合并。上面的是demo,里面的菜单-》表项->插入资质表。请帮我看下。 回复 1楼ninja_aya的帖子
抱歉,这个demo我跑不起来,能否把插入资质表这段代码提取出来发布到论坛上我测试? private void toolStripMenuItem6_Click(object sender, EventArgs e)
{
int nrows = 1;
nrows = nrows + 2;
int iresult = 1600;
if (_textControl.Tables.Add(nrows, 2, iresult))
{
Table t = _textControl.Tables.GetItem(iresult);
FormatTableRow(t.Rows.GetItem(1), 1, 1, 1, 1, true, true);
for (int i = 2; i < nrows; i++)
{
FormatTableRow(t.Rows.GetItem(i), 1, 1, 1, 1, false, true);
}
FormatTableRow(t.Rows.GetItem(nrows), 1, 1, 1, 1, false, true);
int w = t.Columns.GetItem(1).Width + t.Columns.GetItem(2).Width;
t.Columns.GetItem(1).Width = Convert.ToInt32(w * 0.3);
t.Columns.GetItem(2).Width = Convert.ToInt32(w * 0.7);
MergeCells(t, t.Cells.GetItem(1, 1), t.Cells.GetItem(1, 2));
MergeCells(t, t.Cells.GetItem(nrows, 1), t.Cells.GetItem(nrows, 2));
SetCell(t, t.Cells.GetItem(1, 1), "资质要求", "宋体", 8 * 24, true, VerticalAlignment.Center, TXTextControl.HorizontalAlignment.Center);
SetCell(t, t.Cells.GetItem(nrows, 1), "以上资质要求,投标人只要符合任何一条,但同一条中的多项资质要求需同时满足。", "宋体", 8 * 24, true, VerticalAlignment.Center, TXTextControl.HorizontalAlignment.Center);
}
}
private void FormatTableRow(TableRow tr, int left, int right, int bottom, int top, bool ishead, bool pagebreak)
{
tr.CellFormat.LeftBorderColor = System.Drawing.Color.Black;
tr.CellFormat.RightBorderColor = System.Drawing.Color.Black;
tr.CellFormat.BottomBorderColor = System.Drawing.Color.Black;
tr.CellFormat.TopBorderColor = System.Drawing.Color.Black;
tr.CellFormat.LeftTextDistance = 0;
tr.CellFormat.RightTextDistance = 0;
tr.CellFormat.TopTextDistance = 0;
tr.CellFormat.BottomTextDistance = 0;
tr.CellFormat.LeftBorderWidth = left;
tr.CellFormat.RightBorderWidth = right;
tr.CellFormat.TopBorderWidth = top;
tr.CellFormat.BottomBorderWidth = bottom;
tr.IsHeader = ishead;
tr.AllowPageBreak = pagebreak;
}
private void MergeCells(Table t, TableCell begincell, TableCell endcell)
{
_textControl.Selection.Start = begincell.Start - 1;
_textControl.Selection.Length = (endcell.Start + endcell.Length) - (begincell.Start - 1);
t.MergeCells();
}
private void SetCell(Table t, TableCell cell, string value, string fontname, int fontsize, bool bold, VerticalAlignment va, TXTextControl.HorizontalAlignment ha)
{
cell.Text = value;
cell.CellFormat.VerticalAlignment = va;
cell.Select();
_textControl.Selection.FontName = fontname;
_textControl.Selection.FontSize = fontsize;
_textControl.Selection.ParagraphFormat.Alignment = ha;
_textControl.Selection.Bold = bold;
} 回复 3楼ninja_aya的帖子
问题我已经重现了,已经反馈给厂商进行处理,有进一步结果会反馈给你。谢谢 好,请尽快吧。 回复 5楼ninja_aya的帖子
好的,已经在和厂商进行沟通。 回复 3楼ninja_aya的帖子
请修改合并方法为以下代码:
private void MergeCells(Table t, TableCell begincell, TableCell endcell)
{
t.Select(begincell.Row, begincell.Column, endcell.Row, endcell.Column);
t.MergeCells();
}
可以了,谢谢。 回复 8楼ninja_aya的帖子
好的,不客气
为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
http://gcdn.gcpowertools.com.cn/attachment.aspx?attachmentid=10062
页:
[1]