本帖最后由 KingMan 于 2017-6-9 14:01 编辑
private void button13_Click(object sender, EventArgs e)
{
m_iTableId += 1;
if (textControl1.Tables.Add(200, 20, m_iTableId) == false)
{
MessageBox.Show("添加表格失败");
return;
};
}
private void button17_Click(object sender, EventArgs e)
{
TXTextControl.Table pCurrentTable = this.textControl1.Tables.GetItem();
if (pCurrentTable == null)
return;
int i = 1;
TableCellFormat pCellFormat = new TableCellFormat();
pCellFormat.VerticalAlignment = VerticalAlignment.Center;
pCellFormat.LeftBorderColor = Color.Black;
pCellFormat.TopBorderColor = Color.Black;
pCellFormat.RightBorderColor = Color.Black;
pCellFormat.BottomBorderColor = Color.Black;
pCellFormat.LeftBorderWidth = 1;
pCellFormat.TopBorderWidth = 1;
pCellFormat.RightBorderWidth = 1;
pCellFormat.BottomBorderWidth = 1;
foreach (TableCell pNext in pCurrentTable.Cells)
{
pNext.Text = i.ToString();
pNext.CellFormat = pCellFormat;
i += 1;
}
}
就整么一个简单的例子,耗时20 * 200 = 4000 单元格,耗时3分钟还没有搞完,这性能有点问题。。。
下面这个例子,就消耗 2017-06-09 13:52:07 2017-06-09 13:52:46 差不多40s,而且没有什么业务逻辑,如果
加上相关行业业务逻辑,那可用性更加不用说啦,客户完全接受不了这样的用户体验。 40 * (5 * 20) = 4000 单元格
private void button18_Click(object sender, EventArgs e)
{
String sTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
for (int k = 1; k <= 40; k++)
{
m_iTableId += 1;
textControl1.Selection.Text = "\n";
if (textControl1.Tables.Add(5, 20, m_iTableId) == false)
{
MessageBox.Show("添加表格失败");
return;
};
TXTextControl.Table pCurrentTable = this.textControl1.Tables.GetItem(m_iTableId);
if (pCurrentTable == null)
return;
int i = 1;
TableCellFormat pCellFormat = new TableCellFormat();
pCellFormat.VerticalAlignment = VerticalAlignment.Center;
pCellFormat.LeftBorderColor = Color.Black;
pCellFormat.TopBorderColor = Color.Black;
pCellFormat.RightBorderColor = Color.Black;
pCellFormat.BottomBorderColor = Color.Black;
pCellFormat.LeftBorderWidth = 1;
pCellFormat.TopBorderWidth = 1;
pCellFormat.RightBorderWidth = 1;
pCellFormat.BottomBorderWidth = 1;
foreach (TableCell pNext in pCurrentTable.Cells)
{
pNext.Text = i.ToString();
//pNext.CellFormat = pCellFormat;
i += 1;
}
}
sTime += (" " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
textBox3.Text = sTime;
}
|