<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Trials and Tribulations of DataGridView, Column Selections, and Sorting</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/08/26/trials-and-tribulations-of-datagridview-column-selections-and-sorting.aspx</link><description>I had to implement some custom sorting in a DataGridView recently. Essentially, the stakeholders wanted full column selection (like Excel) while still having the ability to sort the data based on a particular column. This particular DataGridView is data</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>re: Trials and Tribulations of DataGridView, Column Selections, and Sorting</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/08/26/trials-and-tribulations-of-datagridview-column-selections-and-sorting.aspx#1675121</link><pubDate>Mon, 02 Mar 2009 05:37:04 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1675121</guid><dc:creator>Sue</dc:creator><description>&lt;p&gt;I tried this and it seemed to work:&lt;/p&gt;
&lt;p&gt;//Get the selected column&lt;/p&gt;
&lt;p&gt;DataGridViewColumn column = dataGridView.SelectedColumns[0];&lt;/p&gt;
&lt;p&gt;//Clear the selection &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;dataGridView.ClearSelection();&lt;/p&gt;
&lt;p&gt;//Sort the column&lt;/p&gt;
&lt;p&gt;dataGridView.Sort(column, ListSortDirection.Descending);&lt;/p&gt;
&lt;p&gt;//Reselect the column &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt;dataGridView.Columns[column.Index].Selected = true;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1675121" width="1" height="1"&gt;</description></item><item><title>re: Trials and Tribulations of DataGridView, Column Selections, and Sorting</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/08/26/trials-and-tribulations-of-datagridview-column-selections-and-sorting.aspx#1673425</link><pubDate>Mon, 23 Feb 2009 21:43:58 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1673425</guid><dc:creator>Steve</dc:creator><description>&lt;p&gt;I can&amp;#39;t believe I&amp;#39;m the only other person on the internet to ever encounter this. There&amp;#39;s no rhyme or reason to it, as far as I can tell, but if you run into this it happens every single time. Quite frustrating in fact.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1673425" width="1" height="1"&gt;</description></item><item><title>Trials and Tribulations of DataGridView, Column Selections, and Sortin</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/08/26/trials-and-tribulations-of-datagridview-column-selections-and-sorting.aspx#1645894</link><pubDate>Tue, 26 Aug 2008 20:13:49 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1645894</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You&amp;#39;ve been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1645894" width="1" height="1"&gt;</description></item></channel></rss>