<p>When designing LINQ classes using the LINQ to SQL designer I've sometimes needed to reorder the classes for the purposes of having the resultant columns in a DataGridView appear in a different order. Unfortunately this seems to be exceedingly difficult; you need to cut and paste properties about, or delete them and re-insert them manually.</p>

<p>I <em>know</em> you can reorder columns fairly easily in a DataGridView, however that would result in a lot of hardcoding and I want the designer to match up to the grid.</p>

<p>Does anyone know of any easier way of achieving this or is cutting/pasting the only available method?</p>

<p>I tried manually editing the .designer.cs file, but reordering properties there doesn't appear to do anything!</p>

<p><strong>Edit:</strong> Just to make it clear - I want to reorder what's in the LINQ to SQL designer, not what's in the table. I haven't made an error in ordering requiring a reversion to the original table layout; rather I have a table which I want to possess a different ordering in Visual Studio than in SQL Server.</p>

[{'answer_id': 37888, 'author': 'Yaakov Ellis', 'author_id': 51, 'author_profile': 'https://Stackoverflow.com/users/51', 'pm_score': 0, 'selected': False, 'text': '<p>If you are in the scenario where you have reordered the columns in the database, and you now want to have this new order be reflected in the designer, I think that you have to delete the table from the designer and then put it in again. Or if you use <a href="http://msdn.microsoft.com/en-us/library/bb386987.aspx" rel="nofollow noreferrer">SqlMetal</a> to generate your Linq-to-Sql classes, rerun it on your database and use the newly generated file.</p>\n'}, {'answer_id': 38259, 'author': 'Yaakov Ellis', 'author_id': 51, 'author_profile': 'https://Stackoverflow.com/users/51', 'pm_score': 2, 'selected': True, 'text': '<p>Using Linq-to-Sql, you can have columns in the DataGridView appear different than in the original table by:</p>\n\n<ol>\n<li>In your Linq query, extract the columns that you want, in the order than you want, and store them in a var. Then the autogenerate columns should show them in that order in the DataGridView</li>\n<li>Use Template columns in your DataGridView</li>\n<li>Do not use drag-and-drop on the Linq-to-Sql design surface to create your entities. Rather, create them by hand and associate them with the database table using table and column properties</li>\n</ol>\n\n<p>As far as I know, there is no drag-and-drop column reorder in the designer itself</p>\n'}, {'answer_id': 35229187, 'author': 'Chad M', 'author_id': 5889161, 'author_profile': 'https://Stackoverflow.com/users/5889161', 'pm_score': 1, 'selected': False, 'text': '<p>Open the [DataClasses].dbml file in your favorite XML editor, and reorder the [Column] elements for the table.  Save, and reopen (or reload) the designer in Visual studio.  The order of the columns displayed in the designer will be fixed.</p>\n'}]
['https://Stackoverflow.com/questions/37882', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3394/']