Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
Christopher Drake 26-Dec-13 10:41am    
Do you want to hide it or get rid of it?

1 solution

If you have grid called fileGrid you can remove the row using the following:
C#
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);
}

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.
 
Share this answer
 
Comments
Member 10284541 2-Jan-14 2:22am    
what is fileGrid.Children??
Christopher Drake 6-Jan-14 8:07am    
That's the name of the grid where you want to remove/hide the row.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900