We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Overriding Keys

I''ve implemented the following code to allow the enter key to move the highlighted row down one row: public class DGridGroupingControl : GridGroupingControl { protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { try { if((keyData & Keys.KeyCode) == Keys.Tab ) { GridCurrentCell cc = this.TableControl.CurrentCell; GridTableCellStyleInfo style = this.TableControl.Model[cc.RowIndex, cc.ColIndex]; if(style != null && style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell) { Point p = this.TableControl.RangeInfoToRectangle(cc.RangeInfo).Location; int x_offset = ((keyData & Keys.Shift) == 0) ? this.TableControl.Model.ColWidths[cc.ColIndex] + 2 : - 2;//this.TableControl.Model.ColWidths[cc.ColIndex - 1] + 2; p.Offset(x_offset, 2); if(x_offset < 0 && cc.ColIndex == this.TableControl.LeftColIndex) this.TableControl.ScrollCellInView(cc.RowIndex, cc.ColIndex - 1); Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(this.TableControl, p); Console.WriteLine("ProcessCmdKey"); return true; } } else if((keyData & Keys.KeyCode) == Keys.Enter) { this.TableControl.CurrentCell.MoveDown(1); } I''m using this code for a grouped grid. The problem I have is when a user hits the enter key, the highlighted summary row is expanded and the next row under the expanded summary is shown and highlighted. The enter key will then move down each detail record with each hit of the key. I''d like the enter key to move the user down each visible row in the grid (in this case summary rows). How can I move down to the next visible row when the user hits the enter key and not expand the summary row?

10 Replies

AA Anthony Avella February 28, 2005 09:39 PM

What is the status of this?? >I''ve implemented the following code to allow the enter key to move the highlighted row down one row: > >public class DGridGroupingControl : GridGroupingControl > { > protected override bool ProcessCmdKey(ref Message msg, Keys keyData) > { > try > { > > if((keyData & Keys.KeyCode) == Keys.Tab ) > { > GridCurrentCell cc = this.TableControl.CurrentCell; > GridTableCellStyleInfo style = this.TableControl.Model[cc.RowIndex, cc.ColIndex]; > if(style != null && style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell) > { > Point p = this.TableControl.RangeInfoToRectangle(cc.RangeInfo).Location; > int x_offset = ((keyData & Keys.Shift) == 0) > ? this.TableControl.Model.ColWidths[cc.ColIndex] + 2 > : - 2;//this.TableControl.Model.ColWidths[cc.ColIndex - 1] + 2; > p.Offset(x_offset, 2); > if(x_offset < 0 && cc.ColIndex == this.TableControl.LeftColIndex) > this.TableControl.ScrollCellInView(cc.RowIndex, cc.ColIndex - 1); > Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(this.TableControl, p); > Console.WriteLine("ProcessCmdKey"); > return true; > } > } > else if((keyData & Keys.KeyCode) == Keys.Enter) > { > this.TableControl.CurrentCell.MoveDown(1); > } >I''m using this code for a grouped grid. > >The problem I have is when a user hits the enter key, the highlighted summary row is expanded and the next row under the expanded summary is shown and highlighted. The enter key will then move down each detail record with each hit of the key. > >I''d like the enter key to move the user down each visible row in the grid (in this case summary rows). > >How can I move down to the next visible row when the user hits the enter key and not expand the summary row? >


AD Administrator Syncfusion Team March 1, 2005 12:50 PM

Hi Anthony, I think it''s just a matter of returning true in your method. I create a sample. Let me know if you see the problem there. SummaryInCaptionWithEnterKey.zip Stefan


AA Anthony Avella March 3, 2005 01:57 PM

Your sample app. is giving me the following unhandled run time sql exception: An unhandled exception of type ''System.Data.SqlClient.SqlException'' occurred in system.data.dll Additional information: System error. @ line 131 of the app. When I add: return true; after: this.TableControl.CurrentCell.MoveDown(1); , as you told me to do, the problem became worse. I also added the OnGroupExpanding(GroupEventArgs e) function, but this made no difference. When I hit the enter key while in a custom caption row, nothing happened at all. Once I expanded the summary row, I was able to hit enter to move through the detail rows (which iseven less than before). Did I need to do more than this? What now? Thanks. >Hi Anthony, > >I think it''s just a matter of returning true in your method. > >I create a sample. Let me know if you see the problem there. > >SummaryInCaptionWithEnterKey.zip > >Stefan >


AD Administrator Syncfusion Team March 3, 2005 02:57 PM

Anthony, Sorry about that - it was because of a change in my code base I temporarily made. That''s why it worked for me. Try replacing the lines as follows: else if((keyData & Keys.KeyCode) == Keys.Enter) { msg.WParam = (IntPtr) Keys.Down; return base.ProcessCmdKey(ref msg, Keys.Down); } Then it should work. Don''t know why you are getting an SQL exception ... All data are loaded from an Xml file. Does it work if you set msdeAvailable = true? But try changing above lines in your code. If that works there is no need to worry why the sample gives an exception on your system. Stefan


AA Anthony Avella March 8, 2005 08:26 AM

There was no xml file in the zip file you sent me. >Anthony, > >Sorry about that - it was because of a change in my code base I temporarily made. That''s why it worked for me. > >Try replacing the lines as follows: > > else if((keyData & Keys.KeyCode) == Keys.Enter) > { > msg.WParam = (IntPtr) Keys.Down; > return base.ProcessCmdKey(ref msg, Keys.Down); > } > >Then it should work. > >Don''t know why you are getting an SQL exception ... All data are loaded from an Xml file. Does it work if you set msdeAvailable = true? But try changing above lines in your code. If that works there is no need to worry why the sample gives an exception on your system. > >Stefan >


AD Administrator Syncfusion Team March 8, 2005 06:40 PM

It''s the same xml file that is used with the SummaryInCaption example. I uploaded it here: Orders.zip Stefan


AA Anthony Avella March 16, 2005 12:49 PM

Sadly, the problem still exists. When I hit the enter key on the grid (in your sample app), the highlighted row only moves down for detail rows. I am unable to move the highlighted row from 1 summary row to another. Any more ideas? My users are expecting this. Thanks. >It''s the same xml file that is used with the SummaryInCaption example. > >I uploaded it here: Orders.zip > >Stefan


AD Administrator Syncfusion Team March 16, 2005 08:06 PM

Stefan, Anthony, I uploaded another version of the sample that works with 3.0.1.0 - that''s the version you have, correct? Click here: CS.zip I orginally used a later version when I worked on the sample. That''s why it worked for me. Sorry about the inconvinience, Stefan


IN Inamul November 15, 2005 11:45 AM

>Your sample app. is giving me the following unhandled run time sql exception: > >An unhandled exception of type ''System.Data.SqlClient.SqlException'' occurred in system.data.dll >Additional information: System error. > > @ line 131 of the app. > >When I add: >return true; >after: > this.TableControl.CurrentCell.MoveDown(1); >, as you told me to do, the problem became worse. > >I also added the OnGroupExpanding(GroupEventArgs e) function, but this made no difference. > >When I hit the enter key while in a custom caption row, nothing happened at all. > >Once I expanded the summary row, I was able to hit enter to move through the detail rows (which iseven less than before). > >Did I need to do more than this? > >What now? > >Thanks. > > > > >>Hi Anthony, >> >>I think it''s just a matter of returning true in your method. >> >>I create a sample. Let me know if you see the problem there. >> >>SummaryInCaptionWithEnterKey.zip >> >>Stefan >>


AD Administrator Syncfusion Team November 15, 2005 01:49 PM

Try hardcoding the line: string xmlDataFileName = @"Data\" + xmlFileName; to use the exact full pathname to where you have the orders.xml file located on your system.

Loader.
Live Chat Icon For mobile
Up arrow icon