none
Worksheet.Change isn't firing when cell value changing through the linked form control check box RRS feed

  • Question

  • Hi,

    Where is Excel workbook working with .Net WinForms app through the functionality of Microsoft.Office.Interop.Excel namespace.

    I'm use Worksheet.Change event to catch value editing in workbook cells. When user edits cell value directly it works fine. However, where is inserted form control checkbox in the book. This checkbox linked to certain cell using "Cell link" property. By checking/unchecking checkbox cell value changes TRUE/FALSE. But in that case event isn't firing.

    Can anyone help me with this situation?

     

    Wednesday, October 19, 2011 4:33 PM

All replies

  • Hi,

    I have tested this as your description, however, the same thing doesn't occur on my side. Here is the steps I tried to repro the issue, please have a check and correct me if there are some mistake:

    1. Create a VSTO document level project

    2. Drag a checkbox control from toolbox and drpp onto the surface of "Sheet2"

    3. Handle CheckedChanged event of the checkbox:

      private void checkBox1_CheckedChanged(object sender, EventArgs e)
            {
                if (checkBox1.Checked == false)
                {
                    rng.Value = "False";
                }
                else
                {
                    rng.Value = "True";
                }
            }
    

    rng is a cell which definded within Sheet2 class:

            Excel.Range rng = null;
            private void Sheet2_Startup(object sender, System.EventArgs e)
            {
                rng = this.Cells[1, 1];
            }
    

    4. Handle the worksheet.Change event:

            private void Sheet2_Change(Excel.Range Target)
            {
                MessageBox.Show("Value changed");
            }
    

    5. Run the solution, checking/unchecking the checkbox can raise up worksheet.change normally.

     

    I look forward to hearing of you.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Calvin_GaoModerator Thursday, October 27, 2011 1:42 PM
    • Unmarked as answer by Trockiy Monday, October 31, 2011 9:48 AM
    Tuesday, October 25, 2011 9:18 AM
    Moderator
  • Thank you for your answer, but i think this is not my case. By "form control checkbox" i meant check box from Excel Ribbon Menu. I have Excel 2007, and i got it from Developer - Controls - Insert - From Controls - Check Box. Sorry for this ambiguity. If you need some more details - please tell me.
    Friday, October 28, 2011 1:15 PM
  • Hi,

    What kind of ribbon are you working with, ribbon designer or ribbon xml? Would you like to post the code of the checkbox and sheet.change event?

    I look forward to hearing of you.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 1, 2011 2:34 AM
    Moderator