tag:blogger.com,1999:blog-8656429443005102101.post5342828239842248263..comments2023-05-16T05:17:07.957-07:00Comments on The Sandpit: Adding Tab-key Support to the PropertyGrid ControlRichiehttp://www.blogger.com/profile/10195785521277646822noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-8656429443005102101.post-45535954012207379412015-09-10T05:15:04.327-07:002015-09-10T05:15:04.327-07:00Thanks for sharing the code, but can you provide s...Thanks for sharing the code, but can you provide step wise clarification of the code please.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656429443005102101.post-10954813015879199132015-09-10T05:13:07.781-07:002015-09-10T05:13:07.781-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/10747516530869640788noreply@blogger.comtag:blogger.com,1999:blog-8656429443005102101.post-7334551083247027122015-05-11T13:43:59.099-07:002015-05-11T13:43:59.099-07:00Thanks for the sharing this code. Is the code abov...Thanks for the sharing this code. Is the code above (if ((Control.ModifierKeys & Keys.Shift) == 0)) supposed to be in the keydown event? If you could share where you placed this snippet for the extra tab press using SendKeys, that would be great. I realize this was published years ago, so I will be lucky to get an answer :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656429443005102101.post-1030496296479748842013-11-21T20:48:31.963-08:002013-11-21T20:48:31.963-08:00I couldn't get Shift+Tab to work for reasons m...I couldn't get Shift+Tab to work for reasons mentioned below. But I came up with a compromise. If someone else solves it I'll be really grateful.<br /><br />The other part of my story is that I also wanted the cursor to be in the value cell, not the property name cell. The original code puts focus on the property name, not the value.<br /><br />If you forget about wanting the cursor in the value cell, you can get Tab and Shift+Tab to step forwards and backwards between property names. with the following code:<br /><br /> if ((Control.ModifierKeys & Keys.Shift) == 0)<br /> {<br /> int nextIndex = index + 1;<br /> if (nextIndex >= gridItems.Count) { return; }<br /> this.SelectedGridItem = gridItems[nextIndex];<br /> }<br /> else<br /> {<br /> int prevIndex = index - 1;<br /> if (prevIndex < 0) { return; }<br /> this.SelectedGridItem = gridItems[prevIndex];<br /> }<br /><br />The 'gotcha' is that you have to press Tab twice to move to another property (once for the property and once for the value). Shift+Tab is another whole world of hurt as after pressing Shift+Tab you have to press Tab again to enter the value cell before pressing another Shift+Tab. Otherwise the focus steps out of the PropertyGrid. You cannot press successive Shift+Tabs.<br /><br />Of course this wasn't what I was after.<br /><br />My solution to getting into the value cell, with one Tab, was to send another Tab using 'SendKey.Send("{Tab}");' straight after the next grid item had been set as in the following code for the 'Tab' key:<br /><br /> if ((Control.ModifierKeys & Keys.Shift) != 0)<br /> {<br /> int nextIndex = index + 1;<br /> if (nextIndex >= gridItems.Count) { return; }<br /> this.SelectedGridItem = gridItems[nextIndex];<br /> SendKeys.Send("{Tab}");<br /> }<br /><br />This is highly counter-intuitive as you'd expect it to move to the next property name field as it would get captured by this code again. Anyway it worked.<br /><br />However this doesn't work for Shift+Tab handling.<br /><br />The 'Shift' key is still being held down when the additional Tab key is sent.<br /><br />If you attempted a single Shift+Tab without the extra SendKey Tab, and then pressed Tab you'd end up in the value cell for the property name you'd Shift+Tabbed(?) to. Have I lost anyone yet? Good.<br /><br />The best I could do was force the Tab to cycle through the property grid starting from the top again when the last property was reached. I've kept the 'Control.Modifiers & Keys.Shift' if ... because... I could.<br /><br /> if ((Control.ModifierKeys & Keys.Shift) == 0)<br /> {<br /> int nextIndex = index + 1;<br /> if (nextIndex >= gridItems.Count)<br /> this.SelectedGridItem = gridItems[0]; // Valid Alternative : gridItems[0].Select();<br /> else<br /> this.SelectedGridItem = gridItems[nextIndex]; // Valid Alternative : gridItems[nextIndex].Select();<br /><br /> SendKeys.Send("{Tab}");<br /> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656429443005102101.post-83412088970445133492013-09-12T02:52:43.514-07:002013-09-12T02:52:43.514-07:00This Property Grid control is able to display the ...This <a href="http://www.kettic.com/winforms_ui/propertygrid.shtml" rel="nofollow">Property Grid control</a> is able to display the properties of any object in a user friendly way and allows the end users of your applications edit the properties of the object.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656429443005102101.post-43158719237340246562013-08-28T08:34:26.147-07:002013-08-28T08:34:26.147-07:00Has anyone been able to implement the Shift-Tab ke...Has anyone been able to implement the Shift-Tab key to navigate backwards?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656429443005102101.post-31077165912415234222009-10-27T05:41:14.826-07:002009-10-27T05:41:14.826-07:00The line of code:
this.SelectedGridItem = gridItem...The line of code:<br />this.SelectedGridItem = gridItems[++index];<br />will overstep the bounds of the gridItems array if you tab past the last grid item.<br /><br />I changed it to:<br />int nextIndex = index + 1;<br />if (nextIndex >= gridItems.Count){return;}<br />// Select next griditem in collection<br />this.SelectedGridItem = gridItems[nextIndex];Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8656429443005102101.post-52528726371532468842009-10-22T10:28:42.638-07:002009-10-22T10:28:42.638-07:00instead of checking whether cursor is inside (why?...instead of checking whether cursor is inside (why??) think better to check ContainsFocus propertyAnonymousnoreply@blogger.com