none
how to proceess the Excel cell click event of a cell

    Question

  • hi,

    I have a added a user control into the actionpane and user can select data from the AP then when then user click ok,  the user selection will be displayed in the active cell.

    I need to do the reverse, meaning, when the user select the data on the cell ( by selecting the cell that has data), I need to update my custom control on the AP to show the value so that users can edit it in the AP.

    I guess this is possible but not sure  how to process the click event and update the AP. appreciate if you could paste some code sample here. thanks


    Thursday, August 02, 2007 9:38 PM

Answers

  • Hi,

    You can response to a SheetSelectionChange event. This event is raised whenever the selected cell or cells in any worksheet within Excel Change. Codes like this: (You can add your own codes to update the AP data where I use a MessageBox to test)

    Code Snippet

    private void ThisAddIn_Startup(object sender, System.EventArgs e)

            {

                this.Application.SheetSelectionChange += new Microsoft.Office.Interop.Excel.AppEvents_SheetSelectionChangeEventHandler(Application_SheetSelectionChange);

            }

     

            void Application_SheetSelectionChange(object Sh, Microsoft.Office.Interop.Excel.Range Target)

            {

                MessageBox.Show("Selection Changed!");

            }

    Hope this helps!

     

    Thanks

    Ji

    Monday, August 06, 2007 2:13 AM
    Moderator

All replies

  • Hi,

    You can response to a SheetSelectionChange event. This event is raised whenever the selected cell or cells in any worksheet within Excel Change. Codes like this: (You can add your own codes to update the AP data where I use a MessageBox to test)

    Code Snippet

    private void ThisAddIn_Startup(object sender, System.EventArgs e)

            {

                this.Application.SheetSelectionChange += new Microsoft.Office.Interop.Excel.AppEvents_SheetSelectionChangeEventHandler(Application_SheetSelectionChange);

            }

     

            void Application_SheetSelectionChange(object Sh, Microsoft.Office.Interop.Excel.Range Target)

            {

                MessageBox.Show("Selection Changed!");

            }

    Hope this helps!

     

    Thanks

    Ji

    Monday, August 06, 2007 2:13 AM
    Moderator
  • Hi,

    It's a nice solution.Helped me a lot.

     

    Thanks

    Krishna

    Monday, April 14, 2008 9:28 AM