Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7901391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:12:26+00:00 2026-06-03T09:12:26+00:00

I have a gridview and if I remove a row in this way: foreach(Label

  • 0

I have a gridview and if I remove a row in this way:

foreach(Label l in currentRow) // I have an internal list of the labels
{
    grdTable.Children.Remove(l); // the cells are filled with labels
}
grdTable.RowDefinitions.Remove(index);

it works if it is the last or second last row in other cases it fails.

an example where row 2. is deleted (index 1)
http://www.pic-upload.de/view-14074618/Unbenannt.png.html

row 3. is not shown and row 2. is really deleted, but it seems to me that row 3. is not correctly pushed on its right place. even updating the grid didn’t help.

edit: the current row is a List<Label> and I have a List<List<Label>> which represents the grid content. I already checked that the List<Label> which fills a row has always the same index as the RowDefinition which holds it.

any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:12:27+00:00Added an answer on June 3, 2026 at 9:12 am

    It looks to me as if you are using a Grid control, as opposed to a ‘GridView’ (I’m not aware of any WPF control with that name.) Your use of RowDefinitions is what suggests this to me.

    Within a Grid, the row each control lies within is given by the value of its Grid.Row attached property. The RowDefinitions of the grid specify the heights of each row.

    When you delete a RowDefinition, all you achieve is adjusting the heights of various rows within the Grid. Deleting a RowDefinition does not affect Grid.Row values of controls within the grid.

    To completely delete the row, you need to:

    1. delete all controls in the row,
    2. shuffle up all controls in rows below the one deleted, and
    3. delete the RowDefinition.

    Your code appears to be missing step 2.

    Your approach works in the case where you delete the last row, because then there are no controls to shuffle up. It also appears to work in the case where you delete the second-last row. Suppose you have 10 rows, numbered from 0 to 9, and you delete row 8. There are now 9 row definitions, with numbers 0 to 8. However, the controls in the last row have their Grid.Row value still set to 9, which is now out of range. WPF puts all controls with the Grid.Row out of range in the last row, so the controls in row 9 appear in row 8. If you add a RowDefinition back to the grid, you’ll find that the controls in row 9 will then appear in the new row 9, leaving a gap in row 8.

    PS. Any reason you’re not using a DataGrid?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView what I fill through a LINQ expression. Something like this:
I have a gridview and in that gridview i created a list of imagebuttons
I have a gridview which has an asp image-button for deleting a row. I
I have a window with a telerik gridview in it and i update this
Ok so I have a GridView like this: <asp:GridView ID=gv runat=server ... > ...
I have gridview, it's datasource is list<string> and I added one checkbox column to
I have WPF ListView with GridView view and I want to remove any trace
I have a Gridview for which Dropdown list has to be added on the
I have a GridView just like this: <asp:GridView ID=gvwStudents runat=server AutoGenerateColumns=False DataKeyNames=ID ShowHeader=False onrowdeleting=gvwStudents_RowDeleting>
i have a grid view with images populated from a list. when i remove

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.