blazor文本字段表



我想为每一行和每一列创建一个文本字段表。理想情况下,应该可以通过某种按钮来扩展每一行和每一列。我正在使用Blazor,我对编程有点陌生,所以我真的不知道如何做到这一点。有人有什么建议吗?

试试:

@code {
private string[,] textInput = new string [100,100];
private int rows = 2;
private int cols = 2;
}
<table class="table">
@for (var i=0; i<rows; i++) {
<tr>
@for (var j=0; j<cols; j++) {
int rowindex = i;
int colindex = j;
<td>
<textarea class="form-control" rows="3" @bind=@textInput[rowindex, colindex] />
</td>
}
</tr>
}
</table>
<button class="btn btn-primary" @onclick=@(() => rows = rows == 100 ? 100 : rows + 1)>Add row</button>
<button class="btn btn-primary" @onclick=@(() => rows = rows == 1 ? 1 : rows - 1)>Remove row</button>
<button class="btn btn-primary" @onclick=@(() => cols = cols == 100 ? 100 : cols + 1)>Add column</button>
<button class="btn btn-primary" @onclick=@(() => cols = cols == 1 ? 1 : cols - 1)>Remove column</button>

相关内容

最新更新