如何在WPF中从Grid中删除一行 [英] How to delete a row from Grid in WPF

查看:881
本文介绍了如何在WPF中从Grid中删除一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题如下:



seleted是Grid中的一个控件;



像这样的代码:

int selectedColumnNumber = Grid.GetRow(已选择);



但是当我想使用代码删除此行时:



grid.RowDefinitions.RemoveAt(selectedColumnNumber);



它总是删除最后一行。我知道当我删除一行时我应该重新定义RowDefinition,



第一次使用此代码时,它仍会删除最后一行。



任何帮助都会感激不尽!!

解决方案

每次删除行定义时,都需要删除此行中的每个控件并重新定义整个rowdefiniton。


检查此链接

从数据网格中删除行 [ ^ ]



从datagrid-wpf中删除一行 [ ^ ]


< blockquote>每次删除一行时,都应删除该行中的rowdefinition和所有子节点。然后重新计算每一行百分比并重新定义整个rwodefinition,然后添加其他子项


I have a strange problem as follow:

seleted is a control in Grid;

the code like this:
int selectedColumnNumber = Grid.GetRow(selected);

but when I want to delete this Row using the code:

grid.RowDefinitions.RemoveAt(selectedColumnNumber);

it always delete the last row. I know when i delete a row I should redefinnition the RowDefinition,

the first time using this code, it still delete the last Row.

any help will be grateful!!

解决方案

Every time you remove a rowdefinition, you need to delete every control in this row and redefine the whole rowdefiniton.


check this links
delete row from datagrid[^]

delete a row from datagrid-wpf[^]


every time remove a row , you should remove the rowdefinition and all children in this row. and then re-compute every row percent and redefine the whole rwodefinition, then add the other children


这篇关于如何在WPF中从Grid中删除一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆