dodo 发表于 2012-10-18 10:58:00

光标定位问题

如何动态实现将光标定位到表中的特定表格里?

iceman 发表于 2012-10-18 15:50:00

回复 1楼dodo的帖子

示例代码如下:

private void Form1_Load(object sender, EventArgs e)
      {
            this.textControl1.Tables.Add(10,10,11);
      }

      private void activeCellToolStripMenuItem_Click(object sender, EventArgs e)
      {
            TXTextControl.Table tb = this.textControl1.Tables.GetItem(11);
            foreach (TXTextControl.TableCell cell in tb.Cells)
            {
                if (cell.Row==2&&cell.Column==2)
                {
                  cell.Select();
                }
            }
      }

dodo 发表于 2012-10-19 09:15:00

我用的是ACtive 版本,没有发现有cell.Select()函数或类似功能函数

iceman 发表于 2012-10-19 18:03:00

回复 3楼dodo的帖子

下面是 TX ActiveX 针对 Table 操作的示例代码:
'

//选择 table
Private Sub SelectTable(tx As TXTextControl)
    With tx
      .SelStart = .TableCellStart(.TableAtInputPos, 1, 1) - 1
      .SelLength = .TableCellStart(.TableAtInputPos, .TableRows(.TableAtInputPos), .TableColumns(.TableAtInputPos)) + _
            .TableCellLength(.TableAtInputPos, .TableRows(.TableAtInputPos), .TableColumns(.TableAtInputPos)) + _
            -.SelStart - 1
    End With
End Sub
//选择 row
Private Sub SelectTableRow(tx As TXTextControl)
    With tx
      .SelStart = .TableCellStart(.TableAtInputPos, .TableRowAtInputPos, 1) - 1
      .SelLength = .TableCellStart(.TableAtInputPos, .TableRowAtInputPos, .TableColumns(.TableAtInputPos)) + _
            .TableCellLength(.TableAtInputPos, .TableRowAtInputPos, .TableColumns(.TableAtInputPos)) + _
            -.SelStart - 1
    End With
End Sub
//选择 col
Private Sub SelectTableColumn(tx As TXTextControl)
    With tx
      .SelStart = .TableCellStart(.TableAtInputPos, 1, .TableColAtInputPos) - 1
      .SelLength = .TableCellStart(.TableAtInputPos, .TableColumns(.TableAtInputPos), .TableColAtInputPos) + _
            .TableCellLength(.TableAtInputPos, .TableColumns(.TableAtInputPos), .TableColAtInputPos) + _
            -.SelStart - 1
    End With
End Sub
//选择 cell
Private Sub SelectTableCell(tx As TXTextControl)
    With tx
      .SelStart = .TableCellStart(.TableAtInputPos, .TableRowAtInputPos, .TableColAtInputPos) - 1
      .SelLength = .TableCellLength(.TableAtInputPos, .TableRowAtInputPos, .TableColAtInputPos)
    End With
End Sub
页: [1]
查看完整版本: 光标定位问题