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 7997445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:57:59+00:00 2026-06-04T14:57:59+00:00

I have a Grid whose Rows & cols are populated dynamically. To delete a

  • 0

I have a Grid whose Rows & cols are populated dynamically. To delete a row I use the following code :

seivesTorGrid.RowDefinitions.RemoveAt(rowIndex+1);

Everything is done manually only. The results of the operations after deleting the row is not satisfactory :
enter image description here

Defination of Grid in xml is :

<Grid Name="seivesTorGrid" ShowGridLines="False" Margin="10, 0, 10, 0"
                  Width="Auto" Height="Auto" >

                <Grid.ColumnDefinitions> </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" MinHeight="25"/>
                </Grid.RowDefinitions>
            </Grid>

This is how I add Cols & Row to the Grid :

        private void AddColumns()
    {
        ColumnDefinition newCol = new ColumnDefinition();
        //newCol.Width = GridLength.Auto;
        newCol.MinWidth = 50;
        newCol.MaxWidth = 150;
        seivesTorGrid.ColumnDefinitions.Add(newCol);

        GridViewColumnHeader gch = new GridViewColumnHeader();
        gch.Content = "ID";
        gch.FontSize = 12;

        Grid.SetColumn(gch, 0);
        seivesTorGrid.Children.Add(gch);

        for (int i = 0; i < GlobalUtils.TOR_List.Count; i++)
        {
            newCol = new ColumnDefinition();
            newCol.Width = GridLength.Auto;
            newCol.MinWidth = 80;
            newCol.MaxWidth = 150;                
            seivesTorGrid.ColumnDefinitions.Add(newCol);

            gch = new GridViewColumnHeader();
            gch.Content = GlobalUtils.TOR_List[i].TOR_Id;
            gch.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            gch.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            gch.FontSize = 12;

            Grid.SetColumn(gch, i + 1);
            seivesTorGrid.Children.Add(gch);                
        }

    }

    private void AddRowToGrid(String id)
    {
        RowDefinition newRow = new RowDefinition();

        seivesTorGrid.RowDefinitions.Add(newRow);
        int rowIndex = seivesTorGrid.RowDefinitions.Count - 1;

        TextBlock idTB = new TextBlock();
        idTB.Text = id;
        idTB.TextAlignment = TextAlignment.Left;
        idTB.VerticalAlignment = System.Windows.VerticalAlignment.Center;

        Grid.SetColumn(idTB, 0);
        Grid.SetRow(idTB, rowIndex);
        seivesTorGrid.Children.Add(idTB);

        for (int i = 1; i < 3; i++)
        {
            Button tempBtn = new Button() {
                Height=25, 
                Width=80,
                Margin = new Thickness(5),
                Content = "Add", 
                Background = Brushes.Brown, 
                Tag = rowIndex
            };

            tempBtn.Click += OnIdButtonClick;

            Grid.SetColumn(tempBtn, i);
            Grid.SetRow(tempBtn, rowIndex);                
            seivesTorGrid.Children.Add(tempBtn);
        }                       
    }

Why the result after deleting the row is not proper? What needs to be corrected?

Any help is highly appreciated.

  • 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-04T14:58:00+00:00Added an answer on June 4, 2026 at 2:58 pm

    You would of course also have to delete all children in that row.

    That means all elements from the seivesTorGrid.Children collection, where Grid.GetRow() returns the index that is to be deleted.

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

Sidebar

Related Questions

I have a grid whose rows need to be resized dynamically based on the
I am using vb.net code. I have grid view, please see the code below:
I have a grid that has multiple rows. I want to hide/show one of
I have a grid view control in my application. Please see the below code.
I have a Grid inside a Canvas defined like this: <Canvas x:Name=outerCanvas> <Grid Grid.Row=1
I have a Silverlight 3 application the inside of whose grid layout root looks
I have a container whose size can change. I will by dynamically creating instances
Some info of the situation: Say I have a grid view of 10 rows
I have the following markup. @(Html.Telerik().Grid(Model) .Name(Grid) .DataKeys(keys => keys.Add(key => key.Id)) .Columns(columns =>
Let's say I have ten rows on a data grid and I have changed

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.