none
How to Simulate Keys (Tab, Escape, Enter, Return) from a WPF control attached to a Cell Editor in EXCEL ? RRS feed

  • Question

  • the EXCEL 2007 AddIn is developed using VS2010, .Net 4.0, WPF as User Controls for Cell Editors.

    One of the Cells has custom editor. The Edito for thsi cell consists of WPF Control (ComboBox)  , User Control (WPF). This Usercontrol is then hosted (added as a child) to ElementHost Control.

    On receiving the focus ont his cell, the user is able to select entries from Dropdown list.

    The issue appears when user hits "ENTER" / "TAB" /  "ESCAPE" / ""RETURN" Keys from the keyboard. It is expected to have the default EXCEL experience i.e.

    ENTER  should select the item from the list and list should close and control should be back on the cell {Cell Editor mode should be closed at this time)

    TAB should select the item from the list and list should close and control should move to next cell on EXCEL worksheet.

    ESCAPE should just cancel user operation /changes.

    I am able to trap these keystrokes in ComboBox's KeyUp event but not sure hwo to simulate the user experience on the EXCEL cells ?

    Any suggestions / advise ?

    Thank you.

    Wednesday, August 8, 2012 7:45 PM

All replies

  • Hi BostonResident,

    As far as I know the Excel Cells can't customize the Editor. Would you please clarify where your Editor set. I think it will not replace the true cell, however your editor covered the cell. Please show me some snippet to clarify your scenario.

    T.X.


    志异征诛,三让两家王朝
    功同开辟,一桮万古江南

    Thursday, August 9, 2012 1:54 AM
  • I am developing a custom EXCEL (2007) AdDIn using VSTO (VS 2010) on .Net 4.0

    One of the cells has a custom editor developed using WPF Control, User Control and ElementHost Control.

    The custom editor seems to be working fine but stops working when worksheet is zoomed to less than 100%.

    I get following message :

    Windows Forms Controls have been disabled because the document has been scaled.When zoom returns to 100, controls will reactivate.

    I found a link that tells this to be a limitation but gies no details or explaination.

    Can anyone explain the details about this behavior and suggest the alternate solution on developin custom cell editors base don WPF controls and ElementHost Controls ?

    Thank you.

    Thursday, August 9, 2012 9:24 PM
  • Hi, the control has to be work with 100% zooming and there's no workaround to it.

    For the original query about simulating keys, I try to get other people help, please wait some time.

    thanks.


    Forrest Guo | MSDN Community Support | Feedback to manager

    Tuesday, August 14, 2012 8:25 AM
    Moderator
  • Hi,

    Please help us better understand the first entry in this thread  describing WPF control(s), a ComboBox drop down, keystrokes and Cell content editing. Is it correct to visualize a dropdown list placed on the Excel worksheet by the VSTO add-in? The end user selects an item from the list and when he/she presses a keyboard key such as 'Enter' the value of the cell becomes that of the selected list item?

    Is it correct to conclude that the list could consist of customer numbers ( or patient numbers,  inventory part numbers, or street names for example )?

    If this describes the business purpose of your project then in general the key click can pass the value of the list item to a method in the add-in that assigns that value (number, text, name etc.) to the value of the cell or range. The addin will need code to determine the active range on that worksheet.

    Please let us know whether this describes what you are doing and whether this is what you want your add-in to do for the end-user. Thanks


    Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen

    Tuesday, August 14, 2012 3:54 PM
    Moderator
  • I am developing custom EXCEL (2007) AddIn using VSTO, .Net 4.0 and WPF Controls.

    One of the requirements required that I develop a custom cell editor using WPF control, UserControl & host in ElementHost control so that it can communicate with EXCEL Engine & Cell Editor.

    The Cell Editor seems to be working except under only one case. The EXCEL throws following message when the worksheet is scaled to below 100 %.

    Windows Forms Controls have been disabled because document has been scaled.When zoom is returned to 100% , the controls will reactivate.

    I searched various forums and found that this is a limitation but none of these forums and/or websites provided any quality explaination for thsi behavior.

    Can someone provide information behind this behavior and/or the alternate solution to  this.

    Thank you.

    

    • Moved by Max Meng Thursday, August 16, 2012 1:39 AM moving to a more appropriate forum (From:Excel IT Pro Discussions)
    • Merged by Jie BaoModerator Thursday, August 16, 2012 7:03 AM duplicate
    Wednesday, August 15, 2012 3:05 PM
  • Hello Boston Resident,

    Your question “Can someone provide information behind this behavior and/or the alternate solution to this?” is in the following document:

    Limitations of Windows Forms Controls on Office Documents
    http://msdn.microsoft.com/en-us/library/ms178765.aspx

    Within the document scroll to the entry on “Control Scaling”

    Also, at the bottom of the document click the link to “Windows Forms Controls on Office Documents Overview.”


    Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen

    Thursday, August 16, 2012 2:00 PM
    Moderator