如何获取 Table 控件中用户更改的单元格的位置(列,行)?

How to get the position(col, row) of the user changed cell in a Table control?

我正在使用 tutorial_Form_Table。

table 具有动态分配的值,例如:

for (col = 1; col <= 5; col++)
{
    for (row = 1; row <= 5; row++)
    {
        if ((col == 2) || (col == 4))
        {
            if (row > 1)
                table.cell(col,row).data(row*col);
            else
                table.cell(col,row).data("Text "+int2str(row*col));
        }
        else
            table.cell(col,row).data("Text "+int2str(row*col));
    }
}

当我在单元格中输入新值时,我需要获取单元格的位置,因此我可以用输入的值更新相应的 table。

谢谢。

Table 有两个属性:row() 和 column(),其中 return 当前活动单元格的值。

public void activeCellChanged()
{
    super();
    info(strFmt('%1 %2 %3', Table.row(), Table.column(), Table.cell(Table.column(), Table.row()).data()));
}

在您添加到 table 控件的每个控件上,您可以覆盖修改后的方法以查看您输入的新值。

public boolean modified()
{
    boolean ret;

    ret = super();

    info(strFmt('New data that we need to save: %1, %2 -> %3', Table.row(), Table.column(), Table.cell(Table.column(), Table.row()).data()));

    return ret;
}

如果您处理大量数据,由于性能问题,您应该考虑使用一些其他控件,例如 .NET 网格控件。