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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:22:36+00:00 2026-06-02T17:22:36+00:00

I am creating a an application with c#, silverlight. I am trying to figure

  • 0

I am creating a an application with c#, silverlight. I am trying to figure out how to reorder the columns in my datagrid after they are autogenerated.

I tried doing something like this:

    private void dataGrid1_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
    {
        switch (e.PropertyName)
        {
            case "taskName":
                {
                    e.Column.DisplayIndex = 0;
                    break;
                }
            case "overallPercentComplete":
                {
                    e.Column.DisplayIndex = 1;
                    break;
                }
            case "TDO_ID":
                {
                    e.Column.DisplayIndex = 2;
                    break;
                }
            case "WBS_ID":
                {
                    e.Column.DisplayIndex = 3;
                    break;
                }
            case "baseLineSD":
                {
                    e.Column.DisplayIndex = 4;
                    break;
                }
            case "baseLineEd":
                {
                    e.Column.DisplayIndex = 5;
                    break;
                }
            case "estimatedSD":
                {
                    e.Column.DisplayIndex = 6;
                    break;
                }
            case "estimatedED":
                {
                    e.Column.DisplayIndex = 7;
                    break;
                }
            case "IMS_Hours":
                {
                    e.Column.DisplayIndex = 8;
                    break;
                }
            case "ETC_Hours":
                {
                    e.Column.DisplayIndex = 9;
                    break;
                }
        }
    }   

This doesn’t exactly work correctly. For this datagrid, the order should be:
taskName, overallPercentComplete, TDO_ID, WBS_ID, baseLineSD, baseLineED, estimatedSD, estimatedED, IMS_Hours, ETC_Hours.

I thought by modifying the Column.DisplayIndex property that would set it up correctly.
However, when this code actually executes, the order is:
taskNme, baseLineEd, TDO_ID, WBS_ID, overallPercentComplete, baseLineSD, estimatedED, estimatedSD, ETC_Hours, IMS_Hours.

Any ideas? Any help would be greatly appreciated. Thanks in advance.

* EDIT *

  void dataGrid1_Loaded(object sender, RoutedEventArgs e)
    {
        dataGrid1.Columns[0].DisplayIndex = 6;
        dataGrid1.Columns[1].DisplayIndex = 7;
        dataGrid1.Columns[2].DisplayIndex = 8;
        dataGrid1.Columns[3].DisplayIndex = 9;
        dataGrid1.Columns[4].DisplayIndex = 4;
        dataGrid1.Columns[5].DisplayIndex = 5;
        dataGrid1.Columns[6].DisplayIndex = 3;
        dataGrid1.Columns[7].DisplayIndex = 2;
        dataGrid1.Columns[8].DisplayIndex = 0;
        dataGrid1.Columns[9].DisplayIndex = 1;
    }

Still nothing, but with the Loaded event handler, I get an error:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Error Details:
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.ObjectModel.Collection`1.get_Item(Int32 index)
at camDashboard.Views.Details.dataGrid1_Loaded(Object sender, RoutedEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)
  • 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-02T17:22:37+00:00Added an answer on June 2, 2026 at 5:22 pm

    Unfortunately this indeed seems to be impossible in Silverlight today.

    Having produced a working solution using the AutoGeneratedColumns event in WPF, I have checked the Silverlight DataGrid source code with Reflector, and first of all, there is no AutoGeneratedColumns event, and second, they indeed sort the columns inside GenerateColumns() (the location your event handler is called from) using a fixed algorithm regardless of your display index settings.

    I can update this placeholder with the WPF solution if it’s of any interest.

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

Sidebar

Related Questions

I'm creating a Silverlight 4 Out Of Browser application. I have my MainPage that
Im attempting to use Silverlight and MVC together. After creating a simple Silverlight application
I am creating an MVVM Silverlight application and am trying to add validation to
After creating a new Silverlight application from the JetPack theme template that was installed,
I am creating an application with silverlight 3.0 . In This application I had
I am creating a Silverlight application which will be heavily javascripted against. To enable
I just finished creating my first major application in C#/Silverlight. In the end the
I'm bumbling my way through creating a Silverlight 3 application. I need some high
I'm currently in the process of creating a Silverlight 3 data driven application. To
I'm trying to establish a HTTP persistent connection from a Silverlight application to a

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.