Q
清除网格单元格
0
A
回答
4
找到更稳定的解决方案,但它需要通过细胞循环:
// these are the row and column number of the cell
// you want to have removed...
int getRow = 2, getCol = 5;
for (int i = 0; i < myGrid.Children.Count; i++)
if ((Grid.GetRow(myGrid.Children[i]) == getRow)
&& (Grid.GetColumn(myGrid.Children[i]) == getCol))
{
myGrid.Children.Remove(myGrid.Children[i]);
break;
}
0
在代码隐藏中,我想?
如果他们是为了申报并填写了所有字段,你可以得到的细胞数量
int cellNumber = rowNumber * columnCount + columnNumber;
然后myGrid.Children[cellNumber-1]
给你你想要的子节点。
myGrid.Children.RemoveAt(ellNumber-1);
将从网格中删除该子节点。
请注意,它只能从网格的子级列表中删除。如果你有任何其他的参考资料,你也必须照顾他们。
+0
对不起,我才意识到我的回答并没有真正解决问题。该解决方案仅适用于所有单元格按从左到右 - >从上到下的顺序声明。 – 2010-08-11 07:44:14
非常感谢,对我感到羞耻我没有得到这个。正在拼命寻找某物。像网格[2] [5] ;-) – 2010-08-11 18:19:36