Drew's Bloghttp://radio.weblogs.com/0104813/
Microsoft .NET, Web Technologies, Personal information, Blogging and various other topics of interest.en-usCopyright 2003 Drew MarshFri, 31 Jan 2003 02:24:08 GMThttp://backend.userland.com/rssRadio UserLand v8.0.6drub0y@hotmail.comdrub0y@hotmail.comrssUpdates2345671060Radio Dies Againhttp://radio.weblogs.com/0104813/2003/01/30.html#a217
This time my worskspace.pt table was missing.http://radio.weblogs.com/0104813/2003/01/30.html#a217Fri, 31 Jan 2003 02:23:59 GMTBloggingHeads Up: Sam Gentile Has Moved His Webloghttp://radio.weblogs.com/0104813/2003/01/30.html#a216
<P><FONT face=Tahoma><EM>Ok, I've had it with Radio and its many bugs, lack of updates, quirks, etc. This is not anything new. I have wanted to move for a very long time to something .NET based but I have not had the time. </EM></FONT><A href="http://aspnetweblog.com/"><FONT face=Tahoma><EM>Scott Watermasysk</EM></FONT></A><FONT face=Tahoma><EM> has graciously volunteered access to his </EM></FONT><A href="http://aspnetweblog.com/archive/01292003.aspx#180"><FONT face=Tahoma><EM>ASP.NET solution and hosting</EM></FONT></A><FONT face=Tahoma><EM>. So I am moving. </EM><A href="http://dotnetweblogs.com/sgentile/Default.aspx"><EM>My new site will be&nbsp;&nbsp;here</EM></A><EM>. The new </EM><A href="http://dotnetweblogs.com/sgentile/Rss.aspx"><EM>RSS feed is here</EM></A><EM>. It will take some time to move over and get things squared away especially with project and book deadlines, and a new baby so please be patient with me. I hope all my loyal readers will continue to read at the new site and as always, I thank each and every one of you for reading my stuff and hope that it continues to help you in youyr work. </EM></FONT>[<A href="http://radio.weblogs.com/0105852/">Sam Gentile's Weblog</A>]</P>
<P>Hmm... I might have to try this out myself.</P>http://radio.weblogs.com/0104813/2003/01/30.html#a216Thu, 30 Jan 2003 18:45:32 GMTSam Gentile's Weblog.NETBloggingVegas Baby!http://radio.weblogs.com/0104813/2003/01/30.html#a215
<P>So, I went out to <A href="http://www.vegas.com">Vegas</A> last weekend for the <A href="http://www.superbowl.com">Super Bowl</A>. It's somewhat of a new ritual that my buddies and I go out there. I took the Bucs on the money line and won myself a decent amount. I was <EM>soooo</EM> close to winning a hefty prop bet too. I had placed $50 on&nbsp;the fact that there would be a 2pt conversion. Three friggin' tries the Raiders had!!! They missed them all. I held my breath while they reviewed the third to see if the guy would have landed in bounds, but alas there was no <A href="http://encarta.msn.com/encnet/features/dictionary/DictionaryResults.aspx?search=irrefutable">irrefutable</A> evidence to overturn the call. It would have paid +300. *sigh*</P>
<P>Unfortunately, I gave over <STRONG>half</STRONG> of it back on the damn <A href="http://www.online-casino-tips.com/craps-rules.html">Craps</A> tables. We just couldn't get a break this weekend when it came to the tables. For anyone who plays, it was basically the annoying pattern of the shooter getting a point, you putting&nbsp;up your odds, place bets, etc.&nbsp;and then the next roll the shooter would seven out. There were only two streaks the entire weekend where more than two points were made by the same shooter. You just can't win under those conditions, unless you're a "Don't" player, but then everyone else at the table hates you. ;) I think I made the most money playing <A href="http://www.freeonlinebets.co.uk/caribbeanpoker-guide.html">Carribean Stud Poker</A> this weekend, which is ironic because it's got some of the, if not&nbsp;<EM>the,</EM> worst odds in the house.</P>
<P>As long as you go out there realizing that the odds are against you and you don't have any silly superstitions, you can always have a good time... and that's exactly what we did.</P>http://radio.weblogs.com/0104813/2003/01/30.html#a215Thu, 30 Jan 2003 17:28:46 GMTPersonalBloggers XBox Live Competition?http://radio.weblogs.com/0104813/2003/01/23.html#a214
<P><A href="http://www.pocketsoap.com/weblog/2003/01/22.html#a980"><EM>xbox</EM></A><EM>. Looks like a </EM><A href="http://radio.weblogs.com/0101039/2003/01/22.html#a551"><EM>few</EM></A><EM> </EM><A href="http://www.snellspace.com/blog/archives/000170.html"><EM>people</EM></A><EM> </EM><A href="http://www.keithba.net/blog/2003_01_01_archive.htm#87830107"><EM>liked</EM></A><EM> the bloggers xbox session idea, but I need some practice, I just&nbsp;got a schoolin' from </EM><A href="http://www.snellspace.com/blog/"><EM>James</EM></A><EM>. My gamertag is zak42.</EM> [<A href="http://www.pocketsoap.com/weblog/">Simon Fell</A>]</P>
<P>Ooooh... I missed the <A href="http://www.pocketsoap.com/weblog/2003/01/21.html#a977">original post</A>, but I'd <EM>love</EM> to get in on the action. My <A href="http://www.xbox.com/live/">XBL</A> gamertag is drub0y. I'm big on <A href="http://www.xbox.com/mechassault/">MechAssault</A> and <A href="http://www.xbox.com/motogp/">MotoGP</A>. I was a beta tester for the service and while I think it's great and has an insane amount of potential, I'm still waiting for the breakthrough game that keeps me online for days at a time. I'm a big fan of racing games, so I'm looking forward to <A href="http://gamespot.com/gamespot/filters/products/0,11114,562117,00.html">PGR2</A>. I'm also a big fan of fighting games, but for some reason the <A href="http://www.xbox.com/mortalkombatdeadlyalliance/default.htm">recently released</A> and <A href="http://www.xbox.com/taofeng/default.htm">soon to be released</A> fighters don't seem to think there's much value in online play. <A href="http://www.xbox.com/capcomvssnk/">Capcom vs. SNK EO</A>, which is supposedly due out early next month, is the only fighting game I know of that's got XBL support. Of course, what we're <EM>all</EM> really waiting for is... <A href="http://www.xbox.com/xboxtv/default.htm?t=932&amp;v=%2Fcms%2F_asx%2Fhalo2%2Fvid-Halo2-PhotoStory-0001&amp;bw=hi&amp;mt=\xboxtv\xboxtvhalo2.htm">Halo2</A>! :)</P>http://radio.weblogs.com/0104813/2003/01/23.html#a214Thu, 23 Jan 2003 16:43:26 GMTSimon FellPersonalRe-Selecting The Currently Selected Row After A DataGrid Sorthttp://radio.weblogs.com/0104813/2003/01/22.html#a213
<P>This is a follow-up to <A href="http://radio.weblogs.com/0104813/categories/net/2003/01/22.html#a212">this previous post</A> about sorting a DataGrid. It turns out that the person who originally asked the question about knowing when the sort would occur, wanted to know this for the purpose of re-selecting the currently selected row after the sort. Well, as it turns out this is entirely possible, but it requires some deeper digging into the data-binding aspects of WinForms (which I love btw). ;)</P>
<P>So here's what you'll need to do. First things first, you're going to need to watch for the sort to happen as was <A href="http://radio.weblogs.com/0104813/categories/net/2003/01/22.html#a212">detailed in the previous post</A>. Upon detecting the sort about to happen you must record a key value for the currently selected row in a state field (probably in your Form). Now, here's where the deeper knowledge of data-binding comes into play. You must also attach an event listener to the <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscurrencymanagerclassitemchangedtopic.asp">ItemChanged event</A> of the <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsCurrencyManagerClassTopic.asp?frame=true">CurrencyManager</A> for the DataTable/DataView you've bound your DataGrid to. The ItemChanged event will fire after the sort takes place at which point you use the DataView's&nbsp;(<A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataTableClassDefaultViewTopic.asp">DataTable::DefaultView</A> if you're bound directly to a DataTable) <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclassfindtopic.asp?frame=true">Find method</A> to locate the row in the view by the key value that you stored in your state field in the sort detection event logic. Once you've found the new position of the row in the&nbsp;DataView after the sort, you set the CurrencyManager's <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsCurrencyManagerClassPositionTopic.asp">Position property</A>&nbsp;to that index. </P>
<P>Ok, this <EM>might</EM> sound complex, but lemme show you just how easy it is with some code. For the purposes of keeping this code concise, assume this code is in a Form subclass which contains a DataGrid in a member variable called "myDataGrid". This DataGrid is then bound to a DataTable, stored in a member variable called "myDataTable"&nbsp;which has a key column named "key" of type int:</P>
<P><CODE>&lt;codeSnippet language="C#"&gt;<BR>public class MyForm : Form<BR>{<BR>&nbsp; private int currentlySelectedRowId = -1;<BR><BR>&nbsp; public MyForm()<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;this.InitializeComponent();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;// Get the&nbsp;CurrencyManager&nbsp;for the bound DataTable<BR>&nbsp;&nbsp;&nbsp;&nbsp;CurrencyManager dataTableCurrencyManager = (CurrencyManager)this.myDataGrid.BindingContext[this.myDataTable];<BR><BR>&nbsp;&nbsp;&nbsp; // Hook up to the ItemChanged event<BR>&nbsp;&nbsp;&nbsp; dataTableCurrencyManager.ItemChanged += new ItemChangeEventHandler(this.myDataTableCurrencyManager_ItemChanged);<BR>&nbsp; }<BR><BR>&nbsp; </CODE><CODE>private void myDataGrid_MouseUp(object sender, MouseEventArgs args)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; DataGrid.HitTestInfo hitTestInfo = this.myDataGrid.HitTest(args.X, args.Y);<BR><BR>&nbsp; &nbsp; if(hitTestInfo.Type == DataGrid.HitTestType.ColumnHeader)<BR>&nbsp; &nbsp; {<BR>&nbsp; &nbsp;&nbsp;&nbsp; // Get the&nbsp;CurrencyManager&nbsp;for the bound DataTable<BR>&nbsp;&nbsp;&nbsp; &nbsp; CurrencyManager dataTableCurrencyManager = (CurrencyManager)this.myDataGrid.BindingContext[this.myDataTable];<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get the current DataRowView<BR>&nbsp; &nbsp;&nbsp;&nbsp; DataRowView currentRowView = (DataRowView)dataTableCurrencyManager.Current;</CODE></P>
<P><CODE>&nbsp;&nbsp;&nbsp; &nbsp; // Remember the currently selected row&nbsp;ID<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.currentlySelectedRowId =&nbsp;(int)currentRowView["key"];<BR>&nbsp; &nbsp; }<BR>&nbsp; }<BR><BR>&nbsp; private void myDataTableCurrencyManager_ItemChanged(object sender, ItemChangeEventArgs args)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; // Only execute this logic if we're in the state of sorting<BR>&nbsp;&nbsp;&nbsp; if(this.currentlySelectedRowId&nbsp;!= -1)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Find the new position of the row now that it's been&nbsp;sorted<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int newPosition = this.myDataTable.DefaultView.Find(this.currentSelectedRowId);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Get the&nbsp;CurrencyManager&nbsp;for the bound DataTable<BR>&nbsp;&nbsp;&nbsp; &nbsp; CurrencyManager dataTableCurrencyManager = (CurrencyManager)this.myDataGrid.BindingContext[this.myDataTable];<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;Change the position of the currency manager<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataTableCurrencyManager.Position = newPosition;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Reset&nbsp;sorting state<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.currentSelectedRowId = -1;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; }&nbsp;<BR>}<BR>&lt;/codeSnippet&gt;</CODE></P>http://radio.weblogs.com/0104813/2003/01/22.html#a213Wed, 22 Jan 2003 18:13:50 GMT.NETDetecting When A DataGrid Is About to Be Re-Sortedhttp://radio.weblogs.com/0104813/2003/01/22.html#a212
<P>A <A href="http://discuss.develop.com/archives/wa.exe?A2=ind0301d&amp;L=dotnet-winforms&amp;T=0&amp;F=&amp;S=&amp;P=461">good question</A> came up on a the <A href="http://discuss.develop.com/dotnet-winforms.html">DOTNET-WINFORMS mailing list</A> this morning. I had to think about it which makes me realize that plenty of other people are probably wondering the same thing: How do you detect when a <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridclasstopic.asp?frame=true">DataGrid</A> is about to be re-sorted?</P>
<P>There is no SortChanged event on the DataGrid. This turns out to be quite annoying, considering the "manual" way to detect a sort. So here's how to do it:</P>
<P>According to the documentation for the <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridtablestyleclassallowsortingtopic.asp">DataGrid::AllowSorting</A> property, clicking on the column header will result in the DataGrid being re-sorted by that column. So with that in mind, take the following steps to detect when a column header has been clicked:</P>
<OL>
<LI>Attach to the DataGrid's MouseUp event.
<LI>In your handler, call <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridclasshittesttopic.asp">DataGrid::HitTest</A>
<LI>Using the <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsDataGridHitTestInfoClassTopic.asp">DataGrid.HitTestInfo</A> returned, inspect the <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridhittestinfoclasstypetopic.asp">DataGrid.HitTestInfo::Type property</A> and check the resulting <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridhittesttypeclasstopic.asp">DataGrid.HitTestType</A>&nbsp;for the ColumnHeader value.</LI></OL>
<P>It would look a little something like this:</P>
<P><CODE>&lt;codeSnippet language="C#"&gt;<BR><BR>private void myDataGrid_MouseUp(object sender, MouseEventArgs args)<BR>{<BR>&nbsp; DataGrid sourceGrid = (DataGrid)sender;<BR><BR>&nbsp; // Perform hit-test<BR>&nbsp; DataGrid.HitTestInfo hitTestInfo = sourceGrid.HitTest(args.X, args.Y);<BR><BR>&nbsp; // Check if a column header was clicked<BR>&nbsp; if(hitTestInfo.Type == DataGrid.HitTestType.ColumnHeader)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; // A column header was clicked,&nbsp;which means a sort occurred.&nbsp;<BR>&nbsp;&nbsp;&nbsp; // Perform any&nbsp;custom logic here.<BR>&nbsp; }<BR>}<BR><BR>&lt;/codeSnippet&gt;</CODE></P>
<P><STRONG>Update:</STRONG> Corrected to use MouseUp event instead of Click event since DataGrid doesn't seem to fire Click event.</P>
<P><STRONG>Update 2:</STRONG> I don't know what I missed the first time I tried it, but the Click event does work for this scenario. If you choose to hook up to that event you can make&nbsp;the HitTest using <A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsControlClassMousePositionTopic.asp">Control::MousePosition</A>.</P>http://radio.weblogs.com/0104813/2003/01/22.html#a212Wed, 22 Jan 2003 16:08:54 GMT.NET