如何在Button上隐藏Silverlight DataGrid中的特定行单击.. [英] How to Hide a particular row in Silverlight DataGrid on Button Click..

查看:75
本文介绍了如何在Button上隐藏Silverlight DataGrid中的特定行单击..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii



我有一个silverlight数据网格。

我想在按钮点击时隐藏该网格中所选行的数据。



请帮帮我。

Hii

I have a silverlight datagrid.
I want to hide the data of a selected row in that grid on button click.

Please help me out.

推荐答案

如果您有名为fileGrid的网格,您可以删除该行使用以下内容:

If you have grid called fileGrid you can remove the row using the following:
private void RemoveFileGridRow(int rowIndex)
{
    for (int controlIndex = 0; controlIndex < fileGrid.Children.Count; controlIndex++)
    {

     UIElement control = fileGrid.Children[controlIndex];
     int currentRowIndex = (int)control.GetValue(Grid.RowProperty);
     if (currentRowIndex == rowIndex)
     {
         fileGrid.Children.RemoveAt(controlIndex--);


     }
     else if (currentRowIndex > rowIndex)
     {
         control.SetValue(Grid.RowProperty, currentRowIndex - 1);
     }
    }

    // lastly remove our row
    fileGrid.RowDefinitions.RemoveAt(rowIndex);
}



这将删除行并在删除的行后重新排序行。



或者,如果要隐藏它,可以将行的高度设置为0.


This will remove the row and reorder the rows after the deleted row.

Alternatively, if you want to hide it, you can set the height of the row to 0.


这篇关于如何在Button上隐藏Silverlight DataGrid中的特定行单击..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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